Fix: Add missing printing module table and improve database management error handling
- Added order_for_labels table to init_db.py (printing/labels module) - Fixed fetch API calls in database management to properly check HTTP response status before parsing JSON - Prevents 'Unexpected token' errors when server returns HTML error pages instead of JSON - Improved error messages for better debugging (shows HTTP status codes) - All 10 database management API endpoints now have proper error handling
This commit is contained in:
25
init_db.py
25
init_db.py
@@ -408,6 +408,31 @@ def create_tables():
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
""", description="Table 'cp_location_history'")
|
||||
|
||||
# Order For Labels table (for printing module)
|
||||
execute_sql(conn, """
|
||||
CREATE TABLE IF NOT EXISTS order_for_labels (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
comanda_productie VARCHAR(50) NOT NULL,
|
||||
cod_articol VARCHAR(50),
|
||||
descr_com_prod TEXT,
|
||||
cantitate DECIMAL(10, 2),
|
||||
com_achiz_client VARCHAR(50),
|
||||
nr_linie_com_client VARCHAR(50),
|
||||
customer_name VARCHAR(255),
|
||||
customer_article_number VARCHAR(100),
|
||||
open_for_order TINYINT(1) DEFAULT 1,
|
||||
line_number INT,
|
||||
printed_labels TINYINT(1) DEFAULT 0,
|
||||
data_livrare DATE,
|
||||
dimensiune VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_comanda_productie (comanda_productie),
|
||||
INDEX idx_printed_labels (printed_labels),
|
||||
INDEX idx_created_at (created_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
""", description="Table 'order_for_labels'")
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
logger.info("✓ All tables created successfully")
|
||||
|
||||
Reference in New Issue
Block a user