| 123456789101112131415161718192021 |
- import db
- query = """
- CREATE TABLE IF NOT EXISTS `warehouse_stock` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `material_id` int(11) NOT NULL,
- `color_name` varchar(100) NOT NULL,
- `quantity` decimal(10,2) DEFAULT 0.00,
- `notes` text DEFAULT NULL,
- `is_active` tinyint(1) DEFAULT 1,
- `created_at` timestamp NULL DEFAULT current_timestamp(),
- `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
- PRIMARY KEY (`id`),
- KEY `material_id` (`material_id`),
- CONSTRAINT `fk_warehouse_material` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) ON DELETE CASCADE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
- """
- try:
- db.execute_commit(query)
- print("TABLE CREATED SUCCESSFULLY")
- except Exception as e:
- print(f"ERROR: {e}")
|