fix on shelf
This commit is contained in:
23
main.go
23
main.go
@@ -102,6 +102,29 @@ func main() {
|
||||
log.Fatal("could not backfill productlocations.publishedat:", err)
|
||||
}
|
||||
|
||||
// The catalogue's own stable key for an imported product.
|
||||
//
|
||||
// `catalogueid` was never able to be this. The catalogue is rebuilt by
|
||||
// scrape and renumbered every time — pepsico's live ids run 3, 6, 9 … 27,
|
||||
// 30 — so a product imported when it was id 26 now points at nothing.
|
||||
// Measured 2026-08-31: eleven of the nineteen links on the platform were
|
||||
// dangling, which silently breaks three things (the "already imported"
|
||||
// ticks, re-importing, and dedupe on the next scrape).
|
||||
//
|
||||
// Additive and nullable: every existing row keeps working, and a re-import
|
||||
// or `/relinkcatalogue` is how one acquires the key.
|
||||
if err := db.DB.Exec(
|
||||
`ALTER TABLE products ADD COLUMN IF NOT EXISTS imageid text`).Error; err != nil {
|
||||
log.Fatal("could not add products.imageid:", err)
|
||||
}
|
||||
// Not unique: two tenants legitimately stock the same catalogue product,
|
||||
// and each keeps its own snapshot row. The lookup is always per tenant.
|
||||
if err := db.DB.Exec(
|
||||
`CREATE INDEX IF NOT EXISTS products_tenant_imageid_idx
|
||||
ON products (tenantid, imageid)`).Error; err != nil {
|
||||
log.Println("⚠️ could not add products.imageid index:", err)
|
||||
}
|
||||
|
||||
// Receipts for spreadsheets sent to the catalogue ingest service.
|
||||
//
|
||||
// The ingest service holds a drop on its own terms: an unreviewed one is
|
||||
|
||||
Reference in New Issue
Block a user