Skip to content

Commit 332cc9d

Browse files
Version 8.0 - Setup bug fix
1 parent 9820fdd commit 332cc9d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

functions/setup.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@
3636
kilo DOUBLE,
3737
type VARCHAR(255),
3838
status VARCHAR(255),
39-
total DOUBLE,
39+
total DECIMAL(10,2),
4040
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
4343
)
4444
");
4545

4646
$db->exec("
4747
CREATE TABLE IF NOT EXISTS items (
4848
id INT PRIMARY KEY AUTO_INCREMENT,
4949
name VARCHAR(255),
50-
price DOUBLE,
50+
price DECIMAL(10,2),
5151
stock INT,
5252
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
5353
)
@@ -57,7 +57,7 @@
5757
CREATE TABLE IF NOT EXISTS prices (
5858
id INT PRIMARY KEY AUTO_INCREMENT,
5959
name VARCHAR(255),
60-
price DOUBLE,
60+
price DECIMAL(10,2),
6161
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
6262
)
6363
");
@@ -69,7 +69,7 @@
6969
logs TEXT,
7070
type TEXT,
7171
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
7373
)
7474
");
7575

@@ -81,9 +81,9 @@
8181
transaction_id INT,
8282
qty INT,
8383
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
8787
)
8888
");
8989

0 commit comments

Comments
 (0)