add product migrations

This commit is contained in:
ryan 2026-05-13 15:52:49 +07:00
parent 12f96c1514
commit 80f2d0e150
2 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,8 @@
-- Remove foreign key constraint
ALTER TABLE products DROP CONSTRAINT IF EXISTS fk_products_outlet;
-- Remove index
DROP INDEX IF EXISTS idx_products_outlet_id;
-- Remove outlet_id column
ALTER TABLE products DROP COLUMN IF EXISTS outlet_id;

View File

@ -0,0 +1,8 @@
-- Add nullable outlet_id column to products table
ALTER TABLE products ADD COLUMN outlet_id UUID;
-- Create index on outlet_id for faster queries
CREATE INDEX idx_products_outlet_id ON products (outlet_id);
-- Add foreign key constraint
ALTER TABLE products ADD CONSTRAINT fk_products_outlet FOREIGN KEY (outlet_id) REFERENCES outlets(id) ON DELETE SET NULL;