pantry-track/sites/default/sql/create/item_locations.sql
2025-04-13 08:27:19 -05:00

14 lines
465 B
SQL

CREATE TABLE IF NOT EXISTS %sitename%_item_locations(
id SERIAL PRIMARY KEY,
part_id INTEGER NOT NULL,
location_id INTEGER NOT NULL,
quantity_on_hand FLOAT8 NOT NULL,
cost_layers INTEGER[] DEFAULT '{}',
UNIQUE(part_id, location_id),
CONSTRAINT fk_part_id
FOREIGN KEY(part_id)
REFERENCES %sitename%_items(id),
CONSTRAINT fk_location_id
FOREIGN KEY(location_id)
REFERENCES %sitename%_locations(id)
);