updated to set boxes , and updated to fill boxes
This commit is contained in:
@@ -216,6 +216,76 @@ def create_boxes_crates_table():
|
||||
print_error(f"Failed to create boxes_crates table: {e}")
|
||||
return False
|
||||
|
||||
def create_box_contents_table():
|
||||
"""Create box_contents table for tracking CP codes in boxes"""
|
||||
print_step(6, "Creating Box Contents Tracking Table")
|
||||
|
||||
try:
|
||||
conn = mariadb.connect(**DB_CONFIG)
|
||||
cursor = conn.cursor()
|
||||
|
||||
box_contents_query = """
|
||||
CREATE TABLE IF NOT EXISTS box_contents (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
box_id BIGINT NOT NULL,
|
||||
cp_code VARCHAR(15) NOT NULL,
|
||||
scan_id BIGINT,
|
||||
scanned_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
scanned_by VARCHAR(100),
|
||||
FOREIGN KEY (box_id) REFERENCES boxes_crates(id) ON DELETE CASCADE,
|
||||
INDEX idx_box_id (box_id),
|
||||
INDEX idx_cp_code (cp_code)
|
||||
);
|
||||
"""
|
||||
cursor.execute(box_contents_query)
|
||||
print_success("Table 'box_contents' created successfully")
|
||||
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print_error(f"Failed to create box_contents table: {e}")
|
||||
return False
|
||||
|
||||
def create_location_contents_table():
|
||||
"""Create location_contents table for tracking boxes in locations"""
|
||||
print_step(7, "Creating Location Contents Tracking Table")
|
||||
|
||||
try:
|
||||
conn = mariadb.connect(**DB_CONFIG)
|
||||
cursor = conn.cursor()
|
||||
|
||||
location_contents_query = """
|
||||
CREATE TABLE IF NOT EXISTS location_contents (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
location_id BIGINT NOT NULL,
|
||||
box_id BIGINT NOT NULL,
|
||||
placed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
placed_by VARCHAR(100),
|
||||
removed_at TIMESTAMP NULL,
|
||||
removed_by VARCHAR(100),
|
||||
status ENUM('active', 'removed') DEFAULT 'active',
|
||||
FOREIGN KEY (location_id) REFERENCES warehouse_locations(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (box_id) REFERENCES boxes_crates(id) ON DELETE CASCADE,
|
||||
INDEX idx_location_id (location_id),
|
||||
INDEX idx_box_id (box_id),
|
||||
INDEX idx_status (status)
|
||||
);
|
||||
"""
|
||||
cursor.execute(location_contents_query)
|
||||
print_success("Table 'location_contents' created successfully")
|
||||
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print_error(f"Failed to create location_contents table: {e}")
|
||||
return False
|
||||
|
||||
def create_permissions_tables():
|
||||
"""Create permission management tables"""
|
||||
print_step(5, "Creating Permission Management Tables")
|
||||
@@ -738,6 +808,8 @@ def main():
|
||||
create_order_for_labels_table,
|
||||
create_warehouse_locations_table,
|
||||
create_boxes_crates_table,
|
||||
create_box_contents_table,
|
||||
create_location_contents_table,
|
||||
create_permissions_tables,
|
||||
create_users_table_mariadb,
|
||||
# create_sqlite_tables, # Disabled - using MariaDB only
|
||||
|
||||
Reference in New Issue
Block a user