Files
website/drizzle/20261025171621_groceries_more_stores/migration.sql
Stan Runge 3f30bb883f
All checks were successful
Deploy production / deploy (push) Successful in 1m7s
groceries: add PLUS, Xenos and Amazing Oriental stores, is_food flag, PLUS EAN backfill
2026-10-25 17:17:53 +00:00

13 lines
1.1 KiB
SQL

ALTER TABLE "groceries"."groups" ADD COLUMN "is_food" boolean DEFAULT true NOT NULL;--> statement-breakpoint
ALTER TABLE "groceries"."items" ADD COLUMN "is_food" boolean DEFAULT true NOT NULL;--> statement-breakpoint
-- New stores (Plus already exists): Xenos and Amazing Oriental (orientalwebshop.nl).
INSERT INTO "groceries"."stores" ("slug", "name", "website", "color", "sort_order") VALUES
('xenos', 'Xenos', 'https://www.xenos.nl', '#e6007e', 50),
('amazing-oriental', 'Amazing Oriental', 'https://www.orientalwebshop.nl/nl/', '#2e7d32', 60)
ON CONFLICT ("slug") DO NOTHING;--> statement-breakpoint
-- Existing AH/Jumbo items: drugstore and household are not food (the importer keeps this current).
UPDATE "groceries"."items" SET "is_food" = false WHERE "category" IN ('Drogisterij', 'Huishouden & dieren');--> statement-breakpoint
UPDATE "groceries"."groups" g SET "is_food" = false
WHERE NOT EXISTS (SELECT 1 FROM "groceries"."items" i WHERE i.group_id = g.id AND i.available AND i.is_food)
AND EXISTS (SELECT 1 FROM "groceries"."items" i WHERE i.group_id = g.id AND i.available);