-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.sql
31 lines (29 loc) · 1.07 KB
/
seed.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
CREATE TABLE users (
id CHAR(36) NOT NULL PRIMARY KEY DEFAULT UUID(),
username VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
CREATE TABLE lists (
id CHAR(36) NOT NULL PRIMARY KEY DEFAULT UUID(),
name VARCHAR(255) NOT NULL,
user_id CHAR(36) NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
CREATE TABLE tasks (
id CHAR(36) NOT NULL PRIMARY KEY DEFAULT UUID(),
name VARCHAR(255) NOT NULL,
note VARCHAR(255),
done BOOLEAN NOT NULL DEFAULT 0,
scheduled DATE,
deadline DATE,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
user_id CHAR(36) NOT NULL,
list_id CHAR(36),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (list_id) REFERENCES lists(id) ON DELETE CASCADE
);