Jadowyne Ulve e01b31ab9a Updated Transaction SCanner to utilize a barcodes
table instead of linked lists.
2025-08-06 15:04:18 -05:00

33 lines
1018 B
SQL

CREATE TABLE IF NOT EXISTS %%site_name%%_items(
id SERIAL PRIMARY KEY,
item_uuid UUID,
barcode VARCHAR(255) NOT NULL,
item_name VARCHAR(255) NOT NULL,
brand INTEGER,
description TEXT,
tags TEXT [],
links JSONB,
item_info_id INTEGER NOT NULL,
logistics_info_id INTEGER NOT NULL,
food_info_id INTEGER,
row_type VARCHAR(255) NOT NULL,
item_type VARCHAR(255) NOT NULL,
search_string TEXT NOT NULL,
UNIQUE(item_uuid, barcode, item_info_id),
CONSTRAINT fk_item_info
FOREIGN KEY(item_info_id)
REFERENCES %%site_name%%_item_info(id)
ON DELETE CASCADE,
CONSTRAINT fk_food_info
FOREIGN KEY(food_info_id)
REFERENCES %%site_name%%_food_info(id)
ON DELETE CASCADE,
CONSTRAINT fk_brand
FOREIGN KEY(brand)
REFERENCES %%site_name%%_brands(id),
CONSTRAINT fk_logistics_info
FOREIGN KEY(logistics_info_id)
REFERENCES %%site_name%%_logistics_info(id)
ON DELETE CASCADE
);