fix in the product import
This commit is contained in:
24
main.go
24
main.go
@@ -78,6 +78,30 @@ func main() {
|
||||
log.Println("⚠️ could not add products.productimages, extra photos will not be stored:", err)
|
||||
}
|
||||
|
||||
// When a product became visible to a store, and the only thing that decides
|
||||
// whether it is.
|
||||
//
|
||||
// `productlocations.status` cannot do this job and was never able to:
|
||||
// syncProductLocationStatus overwrites it with 'available'/'outofstock' on
|
||||
// every stock movement, so the 'Draft' the import wrote survived on exactly
|
||||
// one row out of 6,755. A separate column is untouched by that, and "when
|
||||
// was this published" is worth knowing regardless.
|
||||
//
|
||||
// The backfill is not optional and must land in the same deploy. Membership
|
||||
// of a store catalogue is currently the *existence* of the row, so switching
|
||||
// the read to `publishedat IS NOT NULL` without this empties every shop on
|
||||
// the platform at once.
|
||||
if err := db.DB.Exec(
|
||||
`ALTER TABLE productlocations ADD COLUMN IF NOT EXISTS publishedat timestamp`).Error; err != nil {
|
||||
log.Fatal("could not add productlocations.publishedat:", err)
|
||||
}
|
||||
if err := db.DB.Exec(`
|
||||
UPDATE productlocations
|
||||
SET publishedat = COALESCE(created, NOW())
|
||||
WHERE publishedat IS NULL`).Error; err != nil {
|
||||
log.Fatal("could not backfill productlocations.publishedat:", err)
|
||||
}
|
||||
|
||||
f := facade.NewFacade(db.DB, db.CatalogueDB)
|
||||
|
||||
routes.RegisterRoutes(app, f)
|
||||
|
||||
Reference in New Issue
Block a user