|
36 | 36 | kilo DOUBLE, |
37 | 37 | type VARCHAR(255), |
38 | 38 | status VARCHAR(255), |
39 | | - total DOUBLE, |
| 39 | + total DECIMAL(10,2), |
40 | 40 | created_at DATETIME DEFAULT CURRENT_TIMESTAMP, |
41 | | - FOREIGN KEY (user_id) REFERENCES users(id), |
42 | | - FOREIGN KEY (customer_id) REFERENCES customers(id) |
| 41 | + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, |
| 42 | + FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE CASCADE |
43 | 43 | ) |
44 | 44 | "); |
45 | 45 |
|
46 | 46 | $db->exec(" |
47 | 47 | CREATE TABLE IF NOT EXISTS items ( |
48 | 48 | id INT PRIMARY KEY AUTO_INCREMENT, |
49 | 49 | name VARCHAR(255), |
50 | | - price DOUBLE, |
| 50 | + price DECIMAL(10,2), |
51 | 51 | stock INT, |
52 | 52 | created_at DATETIME DEFAULT CURRENT_TIMESTAMP |
53 | 53 | ) |
|
57 | 57 | CREATE TABLE IF NOT EXISTS prices ( |
58 | 58 | id INT PRIMARY KEY AUTO_INCREMENT, |
59 | 59 | name VARCHAR(255), |
60 | | - price DOUBLE, |
| 60 | + price DECIMAL(10,2), |
61 | 61 | created_at DATETIME DEFAULT CURRENT_TIMESTAMP |
62 | 62 | ) |
63 | 63 | "); |
|
69 | 69 | logs TEXT, |
70 | 70 | type TEXT, |
71 | 71 | created_at DATETIME DEFAULT CURRENT_TIMESTAMP, |
72 | | - FOREIGN KEY (user_id) REFERENCES users(id) |
| 72 | + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE |
73 | 73 | ) |
74 | 74 | "); |
75 | 75 |
|
|
81 | 81 | transaction_id INT, |
82 | 82 | qty INT, |
83 | 83 | created_at DATETIME DEFAULT CURRENT_TIMESTAMP, |
84 | | - FOREIGN KEY (user_id) REFERENCES users(id), |
85 | | - FOREIGN KEY (item_id) REFERENCES items(id), |
86 | | - FOREIGN KEY (transaction_id) REFERENCES transactions(id) |
| 84 | + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, |
| 85 | + FOREIGN KEY (item_id) REFERENCES items(id) ON DELETE CASCADE, |
| 86 | + FOREIGN KEY (transaction_id) REFERENCES transactions(id) ON DELETE CASCADE |
87 | 87 | ) |
88 | 88 | "); |
89 | 89 |
|
|
0 commit comments