Created DROP SQL and started creating setup proc.
This commit is contained in:
parent
7ae046092b
commit
12b838ab3c
Binary file not shown.
BIN
__pycache__/main.cpython-312.pyc
Normal file
BIN
__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
97
main.py
97
main.py
@ -39,23 +39,49 @@ def create_table(sql_file: str):
|
|||||||
if conn is not None:
|
if conn is not None:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
def add_item(barcode: str, name: str):
|
def create_logistics_info(conn, site_name, barcode, quantity_on_hand=0.0):
|
||||||
sql = f"INSERT INTO item_info(barcode) VALUES ('{barcode}') RETURNING id;"
|
sql = f"INSERT INTO {site_name}_logistics_info(barcode, quantity_on_hand) VALUES ('{barcode}', {quantity_on_hand}) RETURNING id;"
|
||||||
database_config = config()
|
logistics_info_id = None
|
||||||
|
try:
|
||||||
|
with conn.cursor() as cur:
|
||||||
|
cur.execute(sql)
|
||||||
|
rows = cur.fetchone()
|
||||||
|
if rows:
|
||||||
|
logistics_info_id = rows[0]
|
||||||
|
except (Exception, psycopg2.DatabaseError) as error:
|
||||||
|
print(error)
|
||||||
|
conn.rollback()
|
||||||
|
return False
|
||||||
|
|
||||||
|
return logistics_info_id
|
||||||
|
|
||||||
|
def create_item_info(conn, site_name, barcode):
|
||||||
|
sql = f"INSERT INTO {site_name}_item_info(barcode) VALUES ('{barcode}') RETURNING id;"
|
||||||
item_info_id = None
|
item_info_id = None
|
||||||
|
try:
|
||||||
|
with conn.cursor() as cur:
|
||||||
|
cur.execute(sql)
|
||||||
|
rows = cur.fetchone()
|
||||||
|
if rows:
|
||||||
|
item_info_id = rows[0]
|
||||||
|
except (Exception, psycopg2.DatabaseError) as error:
|
||||||
|
print(error)
|
||||||
|
conn.rollback()
|
||||||
|
return False
|
||||||
|
|
||||||
|
return item_info_id
|
||||||
|
|
||||||
|
def add_item(site_name: str, barcode: str, name: str):
|
||||||
|
database_config = config()
|
||||||
with psycopg2.connect(**database_config) as conn:
|
with psycopg2.connect(**database_config) as conn:
|
||||||
try:
|
logistics_info_id = create_logistics_info(conn, site_name, barcode)
|
||||||
with conn.cursor() as cur:
|
if not logistics_info_id:
|
||||||
cur.execute(sql)
|
return False
|
||||||
rows = cur.fetchone()
|
item_info_id = create_item_info(conn, site_name, barcode)
|
||||||
if rows:
|
if not item_info_id:
|
||||||
item_info_id = rows[0]
|
|
||||||
except (Exception, psycopg2.DatabaseError) as error:
|
|
||||||
print(error)
|
|
||||||
conn.rollback()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
sqltwo = f"INSERT INTO items(barcode, item_name, item_info_id, row_type, item_type, search_string) VALUES('{barcode}', '{name}', {item_info_id}, 'item', 'other', '{barcode}%{name}') RETURNING *;"
|
sqltwo = f"INSERT INTO {site_name}_items(barcode, item_name, item_info_id, logistics_info_id, row_type, item_type, search_string) VALUES('{barcode}', '{name}', {item_info_id}, {logistics_info_id}, 'item', 'other', '{barcode}%{name}') RETURNING *;"
|
||||||
row = None
|
row = None
|
||||||
try:
|
try:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
@ -90,17 +116,36 @@ def drop_table(sql_file: str):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def delete_site(site_name):
|
||||||
drop_table('sql/drop/item_info.sql')
|
drop_table(f'sites/{site_name}/sql/drop/item_info.sql')
|
||||||
drop_table('sql/drop/items.sql')
|
drop_table(f'sites/{site_name}/sql/drop/items.sql')
|
||||||
create_table('sql/create/logins.sql')
|
drop_table(f'sites/{site_name}/sql/drop/groups.sql')
|
||||||
create_table('sql/create/groups.sql')
|
drop_table(f'sites/{site_name}/sql/drop/linked_items.sql')
|
||||||
create_table('sql/create/linked_items.sql')
|
drop_table(f'sites/{site_name}/sql/drop/transactions.sql')
|
||||||
create_table('sql/create/transactions.sql')
|
drop_table(f'sites/{site_name}/sql/drop/brands.sql')
|
||||||
create_table('sql/create/brands.sql')
|
drop_table(f'sites/{site_name}/sql/drop/food_info.sql')
|
||||||
create_table('sql/create/food_info.sql')
|
drop_table(f'sites/{site_name}/sql/drop/logistics_info.sql')
|
||||||
create_table('sql/create/item_info.sql')
|
|
||||||
create_table('sql/create/item.sql')
|
|
||||||
|
|
||||||
row = add_item(barcode='1237', name='test237')
|
def create_site(site_name):
|
||||||
print(row)
|
create_table(f'sites/{site_name}/sql/create/logins.sql')
|
||||||
|
create_table(f'sites/{site_name}/sql/create/groups.sql')
|
||||||
|
create_table(f'sites/{site_name}/sql/create/linked_items.sql')
|
||||||
|
create_table(f'sites/{site_name}/sql/create/transactions.sql')
|
||||||
|
create_table(f'sites/{site_name}/sql/create/brands.sql')
|
||||||
|
create_table(f'sites/{site_name}/sql/create/food_info.sql')
|
||||||
|
create_table(f'sites/{site_name}/sql/create/item_info.sql')
|
||||||
|
create_table(f'sites/{site_name}/sql/create/logistics_info.sql')
|
||||||
|
create_table(f'sites/{site_name}/sql/create/item.sql')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
#print(add_item(site_name="main", barcode="1235", name="testone"))
|
||||||
|
database_config = config()
|
||||||
|
sql = "SELECT * FROM main_logistics_info WHERE id=2;"
|
||||||
|
with psycopg2.connect(**database_config) as conn:
|
||||||
|
with conn.cursor() as cur:
|
||||||
|
cur.execute(sql)
|
||||||
|
|
||||||
|
rows = cur.fetchone()
|
||||||
|
print(rows)
|
||||||
|
print(type(rows[5]))
|
||||||
74
manage.py
Normal file
74
manage.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
import sys, os, shutil
|
||||||
|
import main
|
||||||
|
|
||||||
|
def rename_drop_sql(site_name):
|
||||||
|
files = os.walk(f"sites/{site_name}/sql/drop")
|
||||||
|
|
||||||
|
sql_files = []
|
||||||
|
for file in files:
|
||||||
|
sql_files = file[2]
|
||||||
|
|
||||||
|
for file_name in sql_files:
|
||||||
|
words = None
|
||||||
|
with open(f"sites/{site_name}/sql/drop/{file_name}", "r") as file:
|
||||||
|
words = file.read()
|
||||||
|
words = words.replace("%sitename%", site_name)
|
||||||
|
|
||||||
|
with open(f"sites/{site_name}/sql/drop/{file_name}", "w") as file:
|
||||||
|
file.write(words)
|
||||||
|
|
||||||
|
def rename_create_sql(site_name):
|
||||||
|
files = os.walk(f"sites/{site_name}/sql/create")
|
||||||
|
|
||||||
|
sql_files = []
|
||||||
|
for file in files:
|
||||||
|
sql_files = file[2]
|
||||||
|
|
||||||
|
for file_name in sql_files:
|
||||||
|
words = None
|
||||||
|
with open(f"sites/{site_name}/sql/create/{file_name}", "r") as file:
|
||||||
|
words = file.read()
|
||||||
|
words = words.replace("%sitename%", site_name)
|
||||||
|
|
||||||
|
with open(f"sites/{site_name}/sql/create/{file_name}", "w") as file:
|
||||||
|
file.write(words)
|
||||||
|
|
||||||
|
|
||||||
|
def create():
|
||||||
|
site_name = input("Site Name: ")
|
||||||
|
site_owner = input("Site Owner: ")
|
||||||
|
email = input("Contact Email: ")
|
||||||
|
|
||||||
|
|
||||||
|
if not os.path.exists(f"sites/{site_name}"):
|
||||||
|
print(f"Creating {site_name} site...")
|
||||||
|
os.mkdir(f"sites/{site_name}")
|
||||||
|
|
||||||
|
print(f"Creating sql tables files...")
|
||||||
|
shutil.copytree(f"sites/default/sql", f"sites/{site_name}/sql")
|
||||||
|
rename_create_sql(site_name)
|
||||||
|
rename_drop_sql(site_name)
|
||||||
|
|
||||||
|
with open(f"sites/{site_name}/site.ini", "w+") as config:
|
||||||
|
config.write(f"[site]\n")
|
||||||
|
config.write(f"site_name={site_name}\n")
|
||||||
|
config.write(f"site_owner={site_owner}\n")
|
||||||
|
config.write(f"email={email}\n")
|
||||||
|
|
||||||
|
print(f"Site {site_name} config created!")
|
||||||
|
print(f"Site {site_name} created!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
func_name = sys.argv[1]
|
||||||
|
|
||||||
|
if func_name == "create_site":
|
||||||
|
create()
|
||||||
|
|
||||||
|
if func_name == "propagate":
|
||||||
|
main.create_site(sys.argv[2])
|
||||||
|
|
||||||
|
if func_name == "delete":
|
||||||
|
main.delete_site(sys.argv[2])
|
||||||
|
shutil.rmtree(f"sites/{sys.argv[2]}")
|
||||||
|
|
||||||
4
sites/default/sql/create/brands.sql
Normal file
4
sites/default/sql/create/brands.sql
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS %sitename%_brands (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
name VARCHAR(255)
|
||||||
|
);
|
||||||
7
sites/default/sql/create/food_info.sql
Normal file
7
sites/default/sql/create/food_info.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS %sitename%_food_info (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
food_groups TEXT [],
|
||||||
|
ingrediants TEXT [],
|
||||||
|
nutrients JSONB,
|
||||||
|
exires BOOLEAN
|
||||||
|
);
|
||||||
8
sites/default/sql/create/groups.sql
Normal file
8
sites/default/sql/create/groups.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS %sitename%_groups(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
description TEXT,
|
||||||
|
included_items INTEGER [],
|
||||||
|
group_type VARCHAR(255),
|
||||||
|
UNIQUE (name)
|
||||||
|
);
|
||||||
28
sites/default/sql/create/item.sql
Normal file
28
sites/default/sql/create/item.sql
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS %sitename%_items(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
barcode VARCHAR(255) NOT NULL,
|
||||||
|
item_name VARCHAR(255) NOT NULL,
|
||||||
|
brand INTEGER,
|
||||||
|
tags TEXT [],
|
||||||
|
links TEXT [],
|
||||||
|
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,
|
||||||
|
quantity_on_hand FLOAT8,
|
||||||
|
UNIQUE(barcode, item_info_id),
|
||||||
|
CONSTRAINT fk_item_info
|
||||||
|
FOREIGN KEY(item_info_id)
|
||||||
|
REFERENCES %sitename%_item_info(id),
|
||||||
|
CONSTRAINT fk_food_info
|
||||||
|
FOREIGN KEY(food_info_id)
|
||||||
|
REFERENCES %sitename%_food_info(id),
|
||||||
|
CONSTRAINT fk_brand
|
||||||
|
FOREIGN KEY(brand)
|
||||||
|
REFERENCES %sitename%_brands(id),
|
||||||
|
CONSTRAINT fk_logistics_info
|
||||||
|
FOREIGN KEY(logistics_info_id)
|
||||||
|
REFERENCES %sitename%_logistics_info(id)
|
||||||
|
);
|
||||||
15
sites/default/sql/create/item_info.sql
Normal file
15
sites/default/sql/create/item_info.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
CREATE TABLE IF NOt EXISTS %sitename%_item_info (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
barcode VARCHAR(255) NOT NULL,
|
||||||
|
linked_items INTEGER [],
|
||||||
|
shopping_lists INTEGER [],
|
||||||
|
recipes INTEGER [],
|
||||||
|
groups INTEGER [],
|
||||||
|
packaging VARCHAR(255),
|
||||||
|
uom VARCHAR(255),
|
||||||
|
cost FLOAT8,
|
||||||
|
safety_stock FLOAT8,
|
||||||
|
lead_time_days FLOAT8,
|
||||||
|
ai_pick BOOLEAN,
|
||||||
|
UNIQUE(barcode)
|
||||||
|
);
|
||||||
8
sites/default/sql/create/linked_items.sql
Normal file
8
sites/default/sql/create/linked_items.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS %sitename%_itemlinks (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
barcode VARCHAR(255) NOt NULL,
|
||||||
|
link INTEGER NOT NULL,
|
||||||
|
data JSONB NOT NULL,
|
||||||
|
conv_factor FLOAT8 NOt NULL,
|
||||||
|
UNIQUE(barcode)
|
||||||
|
);
|
||||||
10
sites/default/sql/create/logistics_info.sql
Normal file
10
sites/default/sql/create/logistics_info.sql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS %sitename%_logistics_info(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
barcode VARCHAR(255) NOT NULL,
|
||||||
|
primary_location VARCHAR(16),
|
||||||
|
auto_issue_location VARCHAR(16),
|
||||||
|
dynamic_locations JSONB,
|
||||||
|
location_data JSONB,
|
||||||
|
quantity_on_hand FLOAT8 NOT NULL,
|
||||||
|
UNIQUE(barcode)
|
||||||
|
);
|
||||||
11
sites/default/sql/create/transactions.sql
Normal file
11
sites/default/sql/create/transactions.sql
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS %sitename%_Transactions (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
timestamp TIMESTAMP,
|
||||||
|
barcode VARCHAR(255) NOT NULL,
|
||||||
|
name VARCHAR(255),
|
||||||
|
transaction_type VARCHAR(255) NOT NULL,
|
||||||
|
quantity FLOAT8 NOT NULL,
|
||||||
|
description TEXT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
data JSONB
|
||||||
|
);
|
||||||
1
sites/default/sql/drop/brands.sql
Normal file
1
sites/default/sql/drop/brands.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE %sitename%_brands CASCADE;
|
||||||
1
sites/default/sql/drop/food_info.sql
Normal file
1
sites/default/sql/drop/food_info.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE %sitename%_food_info CASCADE;
|
||||||
1
sites/default/sql/drop/groups.sql
Normal file
1
sites/default/sql/drop/groups.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE %sitename%_groups CASCADE;
|
||||||
1
sites/default/sql/drop/item_info.sql
Normal file
1
sites/default/sql/drop/item_info.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE %sitename%_item_info CASCADE;
|
||||||
1
sites/default/sql/drop/items.sql
Normal file
1
sites/default/sql/drop/items.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE %sitename%_items CASCADE;
|
||||||
1
sites/default/sql/drop/linked_items.sql
Normal file
1
sites/default/sql/drop/linked_items.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE %sitename%_itemlinks CASCADE;
|
||||||
1
sites/default/sql/drop/logistics_info.sql
Normal file
1
sites/default/sql/drop/logistics_info.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DELETE TABLE %sitename%_logistics_info CASCADE;
|
||||||
1
sites/default/sql/drop/transactions.sql
Normal file
1
sites/default/sql/drop/transactions.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE %sitename%_transactions CASCADE;
|
||||||
4
sites/main/site.ini
Normal file
4
sites/main/site.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[site]
|
||||||
|
site_name=main
|
||||||
|
site_owner=
|
||||||
|
email=
|
||||||
@ -1,4 +1,4 @@
|
|||||||
CREATE TABLE IF NOT EXISTS brands (
|
CREATE TABLE IF NOT EXISTS main_brands (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
name VARCHAR(255)
|
name VARCHAR(255)
|
||||||
);
|
);
|
||||||
@ -1,4 +1,4 @@
|
|||||||
CREATE TABLE IF NOT EXISTS food_info (
|
CREATE TABLE IF NOT EXISTS main_food_info (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
food_groups TEXT [],
|
food_groups TEXT [],
|
||||||
ingrediants TEXT [],
|
ingrediants TEXT [],
|
||||||
@ -1,4 +1,4 @@
|
|||||||
CREATE TABLE IF NOT EXISTS groups(
|
CREATE TABLE IF NOT EXISTS main_groups(
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
name VARCHAR(255) NOT NULL,
|
name VARCHAR(255) NOT NULL,
|
||||||
description TEXT,
|
description TEXT,
|
||||||
@ -1,4 +1,4 @@
|
|||||||
CREATE TABLE IF NOT EXISTS items(
|
CREATE TABLE IF NOT EXISTS main_items(
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
barcode VARCHAR(255) NOT NULL,
|
barcode VARCHAR(255) NOT NULL,
|
||||||
item_name VARCHAR(255) NOT NULL,
|
item_name VARCHAR(255) NOT NULL,
|
||||||
@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS items(
|
|||||||
tags TEXT [],
|
tags TEXT [],
|
||||||
links TEXT [],
|
links TEXT [],
|
||||||
item_info_id INTEGER NOT NULL,
|
item_info_id INTEGER NOT NULL,
|
||||||
|
logistics_info_id INTEGER NOT NULL,
|
||||||
food_info_id INTEGER,
|
food_info_id INTEGER,
|
||||||
row_type VARCHAR(255) NOT NULL,
|
row_type VARCHAR(255) NOT NULL,
|
||||||
item_type VARCHAR(255) NOT NULL,
|
item_type VARCHAR(255) NOT NULL,
|
||||||
@ -14,11 +15,14 @@ CREATE TABLE IF NOT EXISTS items(
|
|||||||
UNIQUE(barcode, item_info_id),
|
UNIQUE(barcode, item_info_id),
|
||||||
CONSTRAINT fk_item_info
|
CONSTRAINT fk_item_info
|
||||||
FOREIGN KEY(item_info_id)
|
FOREIGN KEY(item_info_id)
|
||||||
REFERENCES item_info(id),
|
REFERENCES main_item_info(id),
|
||||||
CONSTRAINT fk_food_info
|
CONSTRAINT fk_food_info
|
||||||
FOREIGN KEY(food_info_id)
|
FOREIGN KEY(food_info_id)
|
||||||
REFERENCES food_info(id),
|
REFERENCES main_food_info(id),
|
||||||
CONSTRAINT fk_brand
|
CONSTRAINT fk_brand
|
||||||
FOREIGN KEY(brand)
|
FOREIGN KEY(brand)
|
||||||
REFERENCES brands(id)
|
REFERENCES main_brands(id),
|
||||||
|
CONSTRAINT fk_logistics_info
|
||||||
|
FOREIGN KEY(logistics_info_id)
|
||||||
|
REFERENCES main_logistics_info(id)
|
||||||
);
|
);
|
||||||
@ -1,4 +1,4 @@
|
|||||||
CREATE TABLE IF NOt EXISTS item_info (
|
CREATE TABLE IF NOt EXISTS main_item_info (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
barcode VARCHAR(255) NOT NULL,
|
barcode VARCHAR(255) NOT NULL,
|
||||||
linked_items INTEGER [],
|
linked_items INTEGER [],
|
||||||
@ -1,4 +1,4 @@
|
|||||||
CREATE TABLE IF NOT EXISTS itemlinks (
|
CREATE TABLE IF NOT EXISTS main_itemlinks (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
barcode VARCHAR(255) NOt NULL,
|
barcode VARCHAR(255) NOt NULL,
|
||||||
link INTEGER NOT NULL,
|
link INTEGER NOT NULL,
|
||||||
16
sites/main/sql/create/logins.sql
Normal file
16
sites/main/sql/create/logins.sql
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS logins(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
username VARCHAR(255),
|
||||||
|
password VARCHAR(255),
|
||||||
|
favorites JSONB,
|
||||||
|
unseen_pantry_items INTEGER [],
|
||||||
|
unseen_groups INTEGER [],
|
||||||
|
unseen_shopping_lists INTEGER [],
|
||||||
|
unseen_recipes INTEGER [],
|
||||||
|
seen_pantry_items INTEGER [],
|
||||||
|
seen_groups INTEGER[],
|
||||||
|
seen_shopping_lists INTEGER [],
|
||||||
|
seen_recipes INTEGER [],
|
||||||
|
flags JSONB
|
||||||
|
);
|
||||||
|
|
||||||
10
sites/main/sql/create/logistics_info.sql
Normal file
10
sites/main/sql/create/logistics_info.sql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS main_logistics_info(
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
barcode VARCHAR(255) NOT NULL,
|
||||||
|
primary_location VARCHAR(16),
|
||||||
|
auto_issue_location VARCHAR(16),
|
||||||
|
dynamic_locations JSONB,
|
||||||
|
location_data JSONB,
|
||||||
|
quantity_on_hand FLOAT8 NOT NULL,
|
||||||
|
UNIQUE(barcode)
|
||||||
|
);
|
||||||
@ -1,4 +1,4 @@
|
|||||||
CREATE TABLE IF NOT EXISTS Transactions (
|
CREATE TABLE IF NOT EXISTS main_Transactions (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
timestamp TIMESTAMP,
|
timestamp TIMESTAMP,
|
||||||
barcode VARCHAR(255) NOT NULL,
|
barcode VARCHAR(255) NOT NULL,
|
||||||
1
sites/main/sql/drop/brands.sql
Normal file
1
sites/main/sql/drop/brands.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE main_brands CASCADE;
|
||||||
1
sites/main/sql/drop/food_info.sql
Normal file
1
sites/main/sql/drop/food_info.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE main_food_info CASCADE;
|
||||||
1
sites/main/sql/drop/groups.sql
Normal file
1
sites/main/sql/drop/groups.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE main_groups CASCADE;
|
||||||
1
sites/main/sql/drop/item_info.sql
Normal file
1
sites/main/sql/drop/item_info.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE main_item_info CASCADE;
|
||||||
1
sites/main/sql/drop/items.sql
Normal file
1
sites/main/sql/drop/items.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE main_items CASCADE;
|
||||||
1
sites/main/sql/drop/linked_items.sql
Normal file
1
sites/main/sql/drop/linked_items.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE main_itemlinks CASCADE;
|
||||||
1
sites/main/sql/drop/logistics_info.sql
Normal file
1
sites/main/sql/drop/logistics_info.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DELETE TABLE main_logistics_info CASCADE;
|
||||||
1
sites/main/sql/drop/transactions.sql
Normal file
1
sites/main/sql/drop/transactions.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
DROP TABLE main_transactions CASCADE;
|
||||||
@ -1 +0,0 @@
|
|||||||
DROP TABLE item_info CASCADE;
|
|
||||||
@ -1 +0,0 @@
|
|||||||
DROP TABLE items CASCADE;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user