This commit is contained in:
aditya.siregar
2025-07-18 20:10:29 +07:00
parent 1bceae010b
commit 4f5950543e
511 changed files with 24132 additions and 34137 deletions
@@ -0,0 +1,16 @@
-- Inventory table
CREATE TABLE inventory (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
outlet_id UUID NOT NULL REFERENCES outlets(id) ON DELETE CASCADE,
product_id UUID NOT NULL REFERENCES products(id) ON DELETE CASCADE,
quantity INTEGER NOT NULL DEFAULT 0 CHECK (quantity >= 0),
reorder_level INTEGER DEFAULT 0 CHECK (reorder_level >= 0),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
UNIQUE(outlet_id, product_id)
);
-- Indexes
CREATE INDEX idx_inventory_outlet_id ON inventory(outlet_id);
CREATE INDEX idx_inventory_product_id ON inventory(product_id);
CREATE INDEX idx_inventory_quantity ON inventory(quantity);
CREATE INDEX idx_inventory_updated_at ON inventory(updated_at);