Add Customer users

This commit is contained in:
Aditya Siregar
2025-08-03 23:55:51 +07:00
parent 96743cf50b
commit 5741243425
69 changed files with 3005 additions and 158 deletions
@@ -0,0 +1,21 @@
-- Product ingredients table
CREATE TABLE product_ingredients (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
organization_id UUID NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
outlet_id UUID REFERENCES outlets(id) ON DELETE CASCADE,
product_id UUID NOT NULL REFERENCES products(id) ON DELETE CASCADE,
ingredient_id UUID NOT NULL REFERENCES ingredients(id) ON DELETE CASCADE,
quantity DECIMAL(12,3) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Indexes
CREATE INDEX idx_product_ingredients_organization_id ON product_ingredients(organization_id);
CREATE INDEX idx_product_ingredients_outlet_id ON product_ingredients(outlet_id);
CREATE INDEX idx_product_ingredients_product_id ON product_ingredients(product_id);
CREATE INDEX idx_product_ingredients_ingredient_id ON product_ingredients(ingredient_id);
CREATE INDEX idx_product_ingredients_created_at ON product_ingredients(created_at);
-- Unique constraint to prevent duplicate product-ingredient combinations
CREATE UNIQUE INDEX idx_product_ingredients_unique ON product_ingredients(product_id, ingredient_id);