12 lines
606 B
SQL
12 lines
606 B
SQL
CREATE TABLE app.inventory_transaction (
|
|
transaction_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
item_id UUID NOT NULL REFERENCES app.inventory_item(item_id),
|
|
quantity_change NUMERIC NOT NULL,
|
|
reason TEXT NOT NULL, -- 'stocktake', 'adjustment', 'consumption', 'restock', 'request_fulfilled'
|
|
notes TEXT,
|
|
created_by_user_id UUID NOT NULL REFERENCES app."user"(user_id),
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
CREATE INDEX idx_inventory_transaction_item ON app.inventory_transaction(item_id);
|
|
CREATE INDEX idx_inventory_transaction_created ON app.inventory_transaction(created_at);
|