File tree 2 files changed +3
-3
lines changed
2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS posts (
10
10
source VARCHAR (2048 ),
11
11
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ,
12
12
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
13
- FOREIGN KEY (user_id) REFERENCES users (id)
13
+ FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
14
14
);
15
15
-- +migrate Down
16
16
DROP TABLE IF EXISTS posts;
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ CREATE TABLE IF NOT EXISTS comments (
12
12
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ,
13
13
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
14
14
PRIMARY KEY (id, post_id),
15
- FOREIGN KEY (post_id) REFERENCES posts (id),
16
- FOREIGN KEY (user_id) REFERENCES users (id)
15
+ FOREIGN KEY (post_id) REFERENCES posts (id) ON DELETE CASCADE ,
16
+ FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
17
17
);
18
18
-- +migrate Down
19
19
DROP TABLE IF EXISTS comments;
You can’t perform that action at this time.
0 commit comments