Skip to content

Commit a6337df

Browse files
committed
feat(migrations): バックエンドでのmigrationの修正に合わせてこっちも修正
1 parent ff2e3f8 commit a6337df

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

.docker/migrations/20210319141439-CreatePosts.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS posts (
1010
source VARCHAR(2048),
1111
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
1212
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
1414
);
1515
-- +migrate Down
1616
DROP TABLE IF EXISTS posts;

.docker/migrations/20210319143039-CreateComments.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ CREATE TABLE IF NOT EXISTS comments (
1212
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
1313
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
1414
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
1717
);
1818
-- +migrate Down
1919
DROP TABLE IF EXISTS comments;

0 commit comments

Comments
 (0)