setup new database schema

This commit is contained in:
Jadowyne Ulve 2025-08-23 15:18:42 -05:00
parent a57b8a2044
commit 0265dd68fc
23 changed files with 358 additions and 223 deletions

View File

@ -1,7 +1,8 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_barcodes (
barcode VARCHAR(32) PRIMARY KEY,
item_uuid UUID,
in_exchange FLOAT,
out_exchange FLOAT,
descriptor VARCHAR(255)
item_uuid UUID PRIMARY KEY REFERENCES %%site_name%%_items(item_uuid) ON DELETE CASCADE,
barcode VARCHAR(32) NOT NULL,
in_exchange FLOAT DEFAULT 0.00 NOT NULL,
out_exchange FLOAT DEFAULT 0.00 NOT NULL,
descriptor VARCHAR(255) DEFAULT '' NOT NULL,
UNIQUE(barcode)
);

View File

@ -1,4 +1,5 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_brands (
id SERIAL PRIMARY KEY,
name VARCHAR(255)
brand_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
brand_name VARCHAR(255) NOT NULL,
UNIQUE(brand_name)
);

View File

@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_conversions (
id SERIAL PRIMARY KEY,
item_id INTEGER NOT NULL,
uom_id INTEGER NOT NULL,
conv_factor FLOAT8 NOT NULL,
UNIQUE(item_id, uom_id)
conversion_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
item_uuid uuid REFERENCES %%site_name%%_items(item_uuid) ON DELETE CASCADE NOT NULL,
conversion_uom_id INTEGER DEFAULT 1 NOT NULL,
conversion_conv_factor FLOAT8 DEFAULT 0.00 NOT NULL,
UNIQUE(item_uuid, conversion_uom_id)
);

View File

@ -1,9 +1,9 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_cost_layers (
id SERIAL PRIMARY KEY,
aquisition_date TIMESTAMP NOT NULL,
quantity FLOAT8 NOT NULL,
cost FLOAT8 NOT NULL,
currency_type VARCHAR(16) NOT NULL,
expires TIMESTAMP,
vendor INTEGER DEFAULT 0
item_location_uuid UUID REFERENCES %%site_name%%_item_locations(item_location_uuid) ON DELETE SET NULL,
layer_aquisition_date TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
layer_quantity FLOAT8 DEFAULT 0.00 NOT NULL,
layer_cost FLOAT8 DEFAULT 0.00 NOT NULL,
layer_currency_type VARCHAR(16) DEFAULT 'USD' NOT NULL,
layer_expires TIMESTAMP DEFAULT NULL,
layer_vendor INTEGER DEFAULT 0 NOT NULL
);

View File

@ -1,10 +1,8 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_food_info (
id SERIAL PRIMARY KEY,
food_info_uuid UUID DEFAULT uuid_generate_v4(),
food_groups TEXT [],
ingrediants TEXT [],
nutrients JSONB,
expires BOOLEAN,
default_expiration FLOAT8,
UNIQUE(food_info_uuid)
item_uuid UUID PRIMARY KEY REFERENCES %%site_name%%_items(item_uuid) ON DELETE CASCADE,
item_food_groups TEXT [] DEFAULT '{}' NOT NULL,
item_ingredients TEXT [] DEFAULT '{}' NOT NULL,
item_nutrients JSONB DEFAULT '{}' NOT NULL,
item_expires BOOLEAN DEFAULT false NOT NULL,
item_default_expiration FLOAT8 DEFAULT 0.00 NOT NULL
);

View File

@ -1,14 +1,11 @@
CREATE TABLE IF NOt EXISTS %%site_name%%_item_info (
id SERIAL PRIMARY KEY,
item_info_uuid UUID DEFAULT uuid_generate_v4(),
barcode VARCHAR(255),
packaging VARCHAR(255),
uom_quantity FLOAT8,
uom INTEGER,
cost FLOAT8,
safety_stock FLOAT8,
lead_time_days FLOAT8,
ai_pick BOOLEAN,
prefixes INTEGER [],
UNIQUE(item_info_uuid)
CREATE TABLE IF NOT EXISTS %%site_name%%_item_info (
item_uuid UUID PRIMARY KEY REFERENCES %%site_name%%_items(item_uuid) ON DELETE CASCADE,
item_uom INTEGER NOT NULL,
item_packaging VARCHAR(255) DEFAULT '' NOT NULL,
item_uom_quantity FLOAT8 DEFAULT 0.00 NOT NULL,
item_cost FLOAT8 DEFAULT 0.00 NOT NULL,
item_safety_stock FLOAT8 DEFAULT 0.00 NOT NULL,
item_lead_time_days FLOAT8 DEFAULT 0.00 NOT NULL,
item_ai_pick BOOLEAN DEFAULT false NOT NULL,
item_prefixes INTEGER [] DEFAULT '{}' NOT NULL
);

View File

@ -1,16 +1,7 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_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 %%site_name%%_items(id)
ON DELETE CASCADE,
CONSTRAINT fk_location_id
FOREIGN KEY(location_id)
REFERENCES %%site_name%%_locations(id)
ON DELETE CASCADE
item_location_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
item_uuid UUID REFERENCES %%site_name%%_items(item_uuid) ON DELETE SET NULL,
location_uuid UUID REFERENCES %%site_name%%_locations(location_uuid) ON DELETE SET NULL,
item_quantity_on_hand FLOAT8 DEFAULT 0.00 NOT NULL,
UNIQUE(item_uuid, location_uuid)
);

View File

@ -1,36 +1,17 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_items(
id SERIAL PRIMARY KEY,
item_uuid UUID DEFAULT uuid_generate_v4(),
barcode VARCHAR(255),
item_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
item_created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
item_updated_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
item_name VARCHAR(255) NOT NULL,
brand INTEGER,
description TEXT,
tags TEXT [],
links JSONB,
item_info_id INTEGER NOT NULL,
item_info_uuid UUID NOT NULL,
logistics_info_id INTEGER NOT NULL,
logistics_info_uuid UUID NOT NULL,
food_info_id INTEGER,
food_info_uuid UUID NOT NULL,
row_type VARCHAR(255) NOT NULL,
item_type VARCHAR(255) NOT NULL,
search_string TEXT NOT NULL,
inactive BOOLEAN DEFAULT false NOT NULL,
UNIQUE(item_uuid),
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,
item_description TEXT DEFAULT '' NOT NULL,
item_tags TEXT [] DEFAULT '{}' NOT NULL,
item_links JSONB DEFAULT '{}' NOT NULL,
item_brand_uuid UUID DEFAULT NULL,
item_category VARCHAR(255) NOT NULL,
item_search_string TEXT DEFAULT '' NOT NULL,
item_inactive BOOLEAN DEFAULT false NOT NULL,
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
FOREIGN KEY(item_brand_uuid)
REFERENCES %%site_name%%_brands(brand_uuid)
ON DELETE SET NULL
);

View File

@ -1,10 +1,6 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_locations(
id SERIAL PRIMARY KEY,
uuid VARCHAR(255) NOT NULL,
name VARCHAR(32) NOT NULL,
zone_id INTEGER NOT NULL,
UNIQUE(uuid),
CONSTRAINT fk_zone
FOREIGN KEY(zone_id)
REFERENCES %%site_name%%_zones(id)
location_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
location_shortname VARCHAR(255) NOT NULL,
location_name VARCHAR(32) NOT NULL,
zone_uuid UUID REFERENCES %%site_name%%_zones(zone_uuid) ON DELETE SET NULL
);

View File

@ -1,22 +1,7 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_logistics_info(
id SERIAL PRIMARY KEY,
logistics_info_uuid UUID DEFAULT uuid_generate_v4(),
barcode VARCHAR(255),
primary_location INTEGER NOT NULL,
primary_zone INTEGER NOT NULL,
auto_issue_location INTEGER NOT NULL,
auto_issue_zone INTEGER NOT NULL,
UNIQUE(logistics_info_uuid),
CONSTRAINT fk_primary_location
FOREIGN KEY(primary_location)
REFERENCES %%site_name%%_locations(id),
CONSTRAINT fk_primary_zone
FOREIGN KEY(primary_zone)
REFERENCES %%site_name%%_zones(id),
CONSTRAINT fk_auto_issue_location
FOREIGN KEY(auto_issue_location)
REFERENCES %%site_name%%_locations(id),
CONSTRAINT fk_auto_issue_zone
FOREIGN KEY(auto_issue_zone)
REFERENCES %%site_name%%_zones(id)
item_uuid UUID PRIMARY KEY REFERENCES %%site_name%%_items(item_uuid) ON DELETE CASCADE,
item_primary_location UUID REFERENCES %%site_name%%_locations(location_uuid) ON DELETE SET NULL,
item_primary_zone UUID REFERENCES %%site_name%%_zones(zone_uuid) ON DELETE SET NULL,
item_auto_issue_location UUID REFERENCES %%site_name%%_locations(location_uuid) ON DELETE SET NULL,
item_auto_issue_zone UUID REFERENCES %%site_name%%_zones(zone_uuid) ON DELETE SET NULL
);

View File

@ -1,14 +1,12 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_plan_events(
id SERIAL PRIMARY KEY,
event_uuid UUID DEFAULT gen_random_uuid(),
plan_uuid UUID,
recipe_uuid UUID,
receipt_uuid UUID DEFAULT NULL,
event_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
event_plan_uuid UUID REFERENCES %%site_name%%_plans(plan_uuid) ON DELETE CASCADE NOT NULL,
event_recipe_uuid UUID DEFAULT NULL,
event_receipt_uuid UUID DEFAULT NULL,
event_shortname VARCHAR(32) NOT NULL,
event_description TEXT,
event_date_start TIMESTAMP NOT NULL,
event_date_end TIMESTAMP NOT NULL,
created_by INTEGER NOT NULL,
event_type VARCHAR(32) NOT NULL,
UNIQUE(event_uuid)
event_description TEXT DEFAULT '' NOT NULL,
event_date_start TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
event_date_end TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
event_created_by INTEGER DEFAULT 1 NOT NULL,
event_type VARCHAR(32) DEFAULT '' NOT NULL
)

View File

@ -1,6 +1,7 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_plans(
plan_uuid UUID PRIMARY KEY DEFAULT gen_random_uuid(),
plan_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
plan_shortname VARCHAR(32) NOT NULL,
plan_description TEXT,
created_by INTEGER NOT NULL
plan_description TEXT DEFAULT '' NOT NULL,
plan_created_by INTEGER DEFAULT 1 NOT NULL,
plan_created_on TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL
)

View File

@ -1,16 +1,11 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_receipt_items (
id SERIAL PRIMARY KEY,
type VARCHAR(255) NOT NULL,
receipt_id INTEGER NOT NULL,
barcode VARCHAR(255),
item_uuid UUID,
name VARCHAR(255) NOT NULL,
qty FLOAT8 NOT NULL,
uom INTEGER NOT NULL,
data JSONB,
status VARCHAR (64),
CONSTRAINT fk_receipt
FOREIGN KEY(receipt_id)
REFERENCES %%site_name%%_receipts(id)
ON DELETE CASCADE
receipt_item_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
receipt_uuid UUID REFERENCES %%site_name%%_receipts(receipt_uuid) ON DELETE CASCADE NOT NULL,
receipt_item_type VARCHAR(255) DEFAULT 'unknown' NOT NULL,
receipt_item_barcode VARCHAR(255) DEFAULT NULL,
receipt_item_name VARCHAR(255) DEFAULT '' NOT NULL,
receipt_item_quantity FLOAT8 DEFAULT 0.00 NOT NULL,
receipt_item_uom INTEGER DEFAULT 1 NOT NULL,
receipt_item_data JSONB DEFAULT '{}' NOT NULL,
receipt_item_status VARCHAR (64) DEFAULT 'unknown' NOT NULL
);

View File

@ -1,13 +1,10 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_receipts (
id SERIAL PRIMARY KEY,
receipt_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
receipt_id VARCHAR (32) NOT NULL,
receipt_status VARCHAR (64) NOT NULL,
date_submitted TIMESTAMP NOT NULL,
submitted_by INTEGER NOT NULL,
vendor_id INTEGER,
files JSONB,
UNIQUE(receipt_id),
CONSTRAINT fk_vendor
FOREIGN KEY(vendor_id)
REFERENCES %%site_name%%_vendors(id)
receipt_status VARCHAR (64) DEFAULT 'Unresolved' NOT NULL,
receipt_created_on TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
receipt_created_by INTEGER DEFAULT 1 NOT NULL,
receipt_vendor_uuid UUID REFERENCES %%site_name%%_vendors(vendor_uuid) ON DELETE RESTRICT,
receipt_files JSONB DEFAULT '{}' NOT NULL,
UNIQUE(receipt_id)
);

View File

@ -1,19 +1,10 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_recipe_items (
id SERIAL PRIMARY KEY,
recipe_item_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
recipe_uuid UUID REFERENCES %%site_name%%_recipes(recipe_uuid) ON DELETE CASCADE NOT NULL,
item_uuid UUID,
rp_id INTEGER NOT NULL,
item_type VARCHAR(32) NOT NULL,
item_name TEXT NOT NULL,
uom INTEGER NOT NULL,
qty FLOAT8 NOT NULL,
item_id INTEGER DEFAULT NULL,
links JSONB DEFAULT '{"main": ""}',
CONSTRAINT fk_rp_id
FOREIGN KEY(rp_id)
REFERENCES %%site_name%%_recipes(id)
ON DELETE CASCADE,
CONSTRAINT fk_item_id
FOREIGN KEY(item_id)
REFERENCES %%site_name%%_items(id)
ON DELETE CASCADE
recipe_item_type VARCHAR(32) DEFAULT 'custom' NOT NULL,
recipe_item_name TEXT DEFAULT '' NOT NULL,
recipe_item_uom INTEGER DEFAULT 1 NOT NULL,
recipe_item_quantity FLOAT8 DEFAULT 0.00 NOT NULL,
links JSONB DEFAULT '{"main": ""}' NOT NULL
);

View File

@ -1,11 +1,10 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_recipes (
id SERIAL PRIMARY KEY,
recipe_uuid UUID DEFAULT gen_random_uuid() NOT NULL,
name VARCHAR,
author INTEGER,
description TEXT,
creation_date TIMESTAMP,
instructions TEXT [],
picture_path TEXT,
UNIQUE(recipe_uuid)
recipe_uuid UUID PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
recipe_name VARCHAR(255) DEFAULT '' NOT NULL,
recipe_created_by INTEGER DEFAULT 1 NOT NULL,
recipe_description TEXT DEFAULT '' NOT NULL,
recipe_creation_date TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
recipe_instructions TEXT [] DEFAULT '{}' NOT NULL,
recipe_picture_path TEXT DEFAULT '' NOT NULL,
UNIQUE(recipe_name)
);

View File

@ -1,12 +1,12 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_shopping_list_items (
list_item_uuid UUID DEFAULT uuid_generate_v4() NOT NULL PRIMARY KEY,
list_uuid UUID NOT NULL,
item_type VARCHAR(32) NOT NULL,
item_name TEXT NOT NULL,
uom INTEGER NOT NULL,
qty FLOAT8 NOT NULL,
list_item_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
list_uuid UUID REFERENCES %%site_name%%_shopping_lists(list_uuid) ON DELETE CASCADE NOT NULL,
list_item_type VARCHAR(32) NOT NULL,
list_item_name VARCHAR(64) DEFAULT '' NOT NULL,
list_item_uom INTEGER DEFAULT 1 NOT NULL,
list_item_quantity FLOAT8 DEFAULT 0.00 NOT NULL,
item_uuid UUID DEFAULT NULL,
links JSONB DEFAULT '{"main": ""}',
list_links JSONB DEFAULT '{"main": ""}',
list_item_state BOOLEAN DEFAULT false,
UNIQUE(list_uuid, item_uuid)
);

View File

@ -1,11 +1,9 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_shopping_lists (
id SERIAL PRIMARY KEY,
list_uuid UUID DEFAULT uuid_generate_v4() NOT NULL,
list_type VARCHAR(32),
name VARCHAR(255) NOT NULL,
description TEXT,
author INTEGER,
creation_date TIMESTAMP,
sub_type VARCHAR(64),
UNIQUE(list_uuid, name)
list_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
list_type VARCHAR(32) NOT NULL,
list_name VARCHAR(255) NOT NULL,
list_description TEXT DEFAULT '' NOT NULL,
list_created_by INTEGER DEFAULT 1 NOT NULL,
list_created_on TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
UNIQUE(list_name)
);

View File

@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_sku_prefix(
id SERIAL PRIMARY KEY,
uuid VARCHAR(16) NOT NULL,
name VARCHAR(255) NOT NULL,
description TEXT,
UNIQUE (name, uuid)
sku_prefix_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
sku_prefix_identifier VARCHAR (32) NOT NULL,
sku_prefix_name VARCHAR(255) DEFAULT '' NOT NULL,
sku_prefix_description TEXT DEFAULT '' NOT NULL,
UNIQUE (sku_prefix_identifier, sku_prefix_name)
);

View File

@ -1,16 +1,11 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_Transactions (
id SERIAL PRIMARY KEY,
timestamp TIMESTAMP,
logistics_info_id INTEGER NOT NULL,
barcode VARCHAR(255),
name VARCHAR(255),
transaction_type VARCHAR(255) NOT NULL,
quantity FLOAT8 NOT NULL,
description TEXT,
user_id INTEGER NOT NULL,
data JSONB,
CONSTRAINT fk_logistics_info
FOREIGN KEY(logistics_info_id)
REFERENCES %%site_name%%_logistics_info(id)
ON DELETE CASCADE
CREATE TABLE IF NOT EXISTS %%site_name%%_transactions (
item_uuid UUID PRIMARY KEY REFERENCES %%site_name%%_items(item_uuid) ON DELETE CASCADE,
transaction_created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
transaction_name VARCHAR(255) DEFAULT NULL,
transaction_type VARCHAR(64) DEFAULT '' NOT NULL,
transaction_quantity FLOAT8 DEFAULT 0.00 NOT NULL,
transaction_description TEXT DEFAULT '' NOT NULL,
transaction_cost FLOAT8 DEFAULT 0.00 NOT NULL,
transaction_created_by INTEGER NOT NULL,
transaction_data JSONB DEFAULT '{}' NOT NULL
);

View File

@ -1,8 +1,9 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_vendors (
id SERIAL PRIMARY KEY,
vendor_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
vendor_name VARCHAR(255) NOT NULL,
vendor_address VARCHAR(255),
creation_date TIMESTAMP NOT NULL,
created_by INTEGER NOT NULL,
phone_number VARCHAR(32)
vendor_address VARCHAR(255) DEFAULT '' NOT NULL,
vendor_phone_number VARCHAR(32) DEFAULT '' NOT NULL,
vendor_creation_date TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
vendor_created_by INTEGER NOT NULL,
UNIQUE(vendor_name, vendor_address, vendor_phone_number)
);

View File

@ -1,6 +1,6 @@
CREATE TABLE IF NOT EXISTS %%site_name%%_zones(
id SERIAL PRIMARY KEY,
name VARCHAR(32) NOT NULL,
description TEXT,
UNIQUE(name)
zone_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
zone_name VARCHAR(32) NOT NULL,
zone_description TEXT DEFAULT '' NOT NULL,
UNIQUE(zone_name)
);

View File

@ -704,3 +704,213 @@
)
,
sql='plans')
2025-08-23 12:31:31.722476 --- ERROR --- DatabaseError(message='relation "test2_item_locations" does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_cost_layers (
item_location_uuid UUID REFERENCES test2_item_locations(item_location_uuid) ON DELETE SET NULL,
layer_aquisition_date TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
layer_quantity FLOAT8 DEFAULT 0.00 NOT NULL,
layer_cost FLOAT8 DEFAULT 0.00 NOT NULL,
layer_currency_type VARCHAR(16) DEFAULT 'USD' NOT NULL,
layer_expires TIMESTAMP DEFAULT NULL,
layer_vendor INTEGER DEFAULT 0 NOT NULL
);,
sql='cost_layers')
2025-08-23 12:31:58.480965 --- ERROR --- DatabaseError(message='relation "test2_items" does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_food_info (
item_uuid UUID PRIMARY KEY REFERENCES test2_items(item_uuid) ON DELETE CASCADE,
food_groups TEXT [] DEFAULT '{}' NOT NULL,
ingredients TEXT [] DEFAULT '{}' NOT NULL,
nutrients JSONB DEFAULT '{}' NOT NULL,
expires BOOLEAN DEFAULT false NOT NULL,
default_expiration FLOAT8 DEFAULT 0.00 NOT NULL
);,
sql='food_info')
2025-08-23 12:32:33.418128 --- ERROR --- DatabaseError(message='relation "test2_logistics_info" does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_Transactions (
id SERIAL PRIMARY KEY,
timestamp TIMESTAMP,
logistics_info_id INTEGER NOT NULL,
barcode VARCHAR(255),
name VARCHAR(255),
transaction_type VARCHAR(255) NOT NULL,
quantity FLOAT8 NOT NULL,
description TEXT,
user_id INTEGER NOT NULL,
data JSONB,
CONSTRAINT fk_logistics_info
FOREIGN KEY(logistics_info_id)
REFERENCES test2_logistics_info(id)
ON DELETE CASCADE
);,
sql='transactions')
2025-08-23 12:32:59.145550 --- ERROR --- DatabaseError(message='column "brand_uuid" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_items(
item_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
item_name VARCHAR(255) NOT NULL,
item_description TEXT DEFAULT '' NOT NULL,
item_tags TEXT [] DEFAULT '{}' NOT NULL,
item_links JSONB DEFAULT '{}' NOT NULL,
brand_uuid UUID DEFAULT NULL,
item_category VARCHAR(255) NOT NULL,
search_string TEXT DEFAULT '' NOT NULL,
inactive BOOLEAN DEFAULT false NOT NULL,
CONSTRAINT fk_brand
FOREIGN KEY(brand_uuid)
REFERENCES test2_brands(brand_uuid)
ON DELETE SET NULL
);
,
sql='items')
2025-08-23 12:33:48.793121 --- ERROR --- DatabaseError(message='column "brand_uuid" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_items(
item_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
item_name VARCHAR(255) NOT NULL,
item_description TEXT DEFAULT '' NOT NULL,
item_tags TEXT [] DEFAULT '{}' NOT NULL,
item_links JSONB DEFAULT '{}' NOT NULL,
brand_uuid UUID DEFAULT NULL,
item_category VARCHAR(255) NOT NULL,
search_string TEXT DEFAULT '' NOT NULL,
inactive BOOLEAN DEFAULT false NOT NULL,
CONSTRAINT fk_brand
FOREIGN KEY(brand_uuid)
REFERENCES test2_brands(brand_uuid)
ON DELETE SET NULL
);
,
sql='items')
2025-08-23 12:34:28.182864 --- ERROR --- DatabaseError(message='table "test2_cost_layers" does not exist',
payload=DROP TABLE test2_cost_layers CASCADE;,
sql='cost_layers')
2025-08-23 13:32:49.821424 --- ERROR --- DatabaseError(message='column "zones_uuid" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_logistics_info(
item_uuid UUID PRIMARY KEY REFERENCES test2_items(item_uuid) ON DELETE CASCADE,
primary_location UUID REFERENCES test2_locations(zones_uuid) ON DELETE SET NULL,
primary_zone UUID REFERENCES test2_zones(zones_uuid) ON DELETE SET NULL,
auto_issue_location UUID REFERENCES test2_locations(zones_uuid) ON DELETE SET NULL,
auto_issue_zone UUID REFERENCES test2_zones(zones_uuid) ON DELETE SET NULL
);,
sql='logistics_info')
2025-08-23 13:33:48.791869 --- ERROR --- DatabaseError(message='table "test2_cost_layers" does not exist',
payload=DROP TABLE test2_cost_layers CASCADE;,
sql='cost_layers')
2025-08-23 13:36:33.932188 --- ERROR --- DatabaseError(message='column "zones_uuid" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_logistics_info(
item_uuid UUID PRIMARY KEY REFERENCES test2_items(item_uuid) ON DELETE CASCADE,
primary_location UUID REFERENCES test2_locations(zones_uuid) ON DELETE SET NULL,
primary_zone UUID REFERENCES test2_zones(zones_uuid) ON DELETE SET NULL,
auto_issue_location UUID REFERENCES test2_locations(zones_uuid) ON DELETE SET NULL,
auto_issue_zone UUID REFERENCES test2_zones(zones_uuid) ON DELETE SET NULL
);,
sql='logistics_info')
2025-08-23 13:37:28.841496 --- ERROR --- DatabaseError(message='column "zones_uuid" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_logistics_info(
item_uuid UUID PRIMARY KEY REFERENCES test2_items(item_uuid) ON DELETE CASCADE,
primary_location UUID REFERENCES test2_locations(zones_uuid) ON DELETE SET NULL,
primary_zone UUID REFERENCES test2_zones(zones_uuid) ON DELETE SET NULL,
auto_issue_location UUID REFERENCES test2_locations(zones_uuid) ON DELETE SET NULL,
auto_issue_zone UUID REFERENCES test2_zones(zones_uuid) ON DELETE SET NULL
);,
sql='logistics_info')
2025-08-23 13:38:23.460512 --- ERROR --- DatabaseError(message='there is no unique constraint matching given keys for referenced table "test2_locations"',
payload=CREATE TABLE IF NOT EXISTS test2_logistics_info(
item_uuid UUID PRIMARY KEY REFERENCES test2_items(item_uuid) ON DELETE CASCADE,
primary_location UUID REFERENCES test2_locations(zone_uuid) ON DELETE SET NULL,
primary_zone UUID REFERENCES test2_zones(zone_uuid) ON DELETE SET NULL,
auto_issue_location UUID REFERENCES test2_locations(zone_uuid) ON DELETE SET NULL,
auto_issue_zone UUID REFERENCES test2_zones(zone_uuid) ON DELETE SET NULL
);,
sql='logistics_info')
2025-08-23 13:38:58.644650 --- ERROR --- DatabaseError(message='column "id" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_Transactions (
id SERIAL PRIMARY KEY,
timestamp TIMESTAMP,
logistics_info_id INTEGER NOT NULL,
barcode VARCHAR(255),
name VARCHAR(255),
transaction_type VARCHAR(255) NOT NULL,
quantity FLOAT8 NOT NULL,
description TEXT,
user_id INTEGER NOT NULL,
data JSONB,
CONSTRAINT fk_logistics_info
FOREIGN KEY(logistics_info_id)
REFERENCES test2_logistics_info(id)
ON DELETE CASCADE
);,
sql='transactions')
2025-08-23 13:44:59.778889 --- ERROR --- DatabaseError(message='column "logistics_info_uuid" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_transactions (
logistics_info_uuid INTEGER PRIMARY KEY REFERENCES test2_logistics_info(logistics_info_uuid) ON DELETE CASCADE,
transaction_created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
transaction_name VARCHAR(255) DEFAULT NULL,
transaction_type VARCHAR(64) DEFAULT '' NOT NULL,
transaction_quantity FLOAT8 DEFAULT 0.00 NOT NULL,
transaction_description TEXT DEFAULT '' NOT NULL,
transaction_cost FLOAT8 DEFAULT 0.00 NOT NULL,
user_id INTEGER NOT NULL,
transaction_data JSONB DEFAULT '{}' NOT NULL
);,
sql='transactions')
2025-08-23 13:45:12.041464 --- ERROR --- DatabaseError(message='column "logistics_info_uuid" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_transactions (
logistics_info_uuid UUID PRIMARY KEY REFERENCES test2_logistics_info(logistics_info_uuid) ON DELETE CASCADE,
transaction_created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
transaction_name VARCHAR(255) DEFAULT NULL,
transaction_type VARCHAR(64) DEFAULT '' NOT NULL,
transaction_quantity FLOAT8 DEFAULT 0.00 NOT NULL,
transaction_description TEXT DEFAULT '' NOT NULL,
transaction_cost FLOAT8 DEFAULT 0.00 NOT NULL,
user_id INTEGER NOT NULL,
transaction_data JSONB DEFAULT '{}' NOT NULL
);,
sql='transactions')
2025-08-23 13:47:37.787017 --- ERROR --- DatabaseError(message='column "id" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_recipe_items (
id SERIAL PRIMARY KEY,
item_uuid UUID,
rp_id INTEGER NOT NULL,
item_type VARCHAR(32) NOT NULL,
item_name TEXT NOT NULL,
uom INTEGER NOT NULL,
qty FLOAT8 NOT NULL,
item_id INTEGER DEFAULT NULL,
links JSONB DEFAULT '{"main": ""}',
CONSTRAINT fk_rp_id
FOREIGN KEY(rp_id)
REFERENCES test2_recipes(id)
ON DELETE CASCADE,
CONSTRAINT fk_item_id
FOREIGN KEY(item_id)
REFERENCES test2_items(id)
ON DELETE CASCADE
);,
sql='recipe_items')
2025-08-23 14:16:10.788720 --- ERROR --- DatabaseError(message='column "item_id" named in key does not existLINE 6: UNIQUE(item_id, conversion_uom_id) ^',
payload=CREATE TABLE IF NOT EXISTS test2_conversions (
conversion_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
item_uuid uuid REFERENCES test2_items(item_uuid) ON DELETE CASCADE NOT NULL,
conversion_uom_id INTEGER DEFAULT 1 NOT NULL,
conversion_conv_factor FLOAT8 DEFAULT 0.00 NOT NULL,
UNIQUE(item_id, conversion_uom_id)
);,
sql='conversions')
2025-08-23 14:16:21.833781 --- ERROR --- DatabaseError(message='column "id" referenced in foreign key constraint does not exist',
payload=CREATE TABLE IF NOT EXISTS test2_receipts (
id SERIAL PRIMARY KEY,
receipt_id VARCHAR (32) NOT NULL,
receipt_status VARCHAR (64) NOT NULL,
date_submitted TIMESTAMP NOT NULL,
submitted_by INTEGER NOT NULL,
vendor_id INTEGER,
files JSONB,
UNIQUE(receipt_id),
CONSTRAINT fk_vendor
FOREIGN KEY(vendor_id)
REFERENCES test2_vendors(id)
);,
sql='receipts')