feat: add printer types
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
-- Only the first printer fits back into printer_type; the extra stations are lost.
|
||||
ALTER TABLE products ADD COLUMN printer_type VARCHAR(50) DEFAULT 'kitchen';
|
||||
|
||||
UPDATE products SET printer_type = COALESCE(printer_types->>0, '');
|
||||
|
||||
CREATE INDEX idx_products_printer_type ON products(printer_type);
|
||||
|
||||
ALTER TABLE products DROP COLUMN printer_types;
|
||||
@@ -0,0 +1,12 @@
|
||||
-- A product can be prepared at more than one station: a meal-and-drink package goes to
|
||||
-- the kitchen and to the bar. printer_types replaces the single printer_type.
|
||||
ALTER TABLE products ADD COLUMN printer_types JSONB NOT NULL DEFAULT '["kitchen"]';
|
||||
|
||||
UPDATE products
|
||||
SET printer_types = CASE
|
||||
WHEN COALESCE(printer_type, '') = '' THEN '[]'::jsonb
|
||||
ELSE jsonb_build_array(printer_type)
|
||||
END;
|
||||
|
||||
-- Dropping the column drops idx_products_printer_type with it.
|
||||
ALTER TABLE products DROP COLUMN printer_type;
|
||||
Reference in New Issue
Block a user