Fix issue with sqlite migrations for comment_seers (#503)
This commit is contained in:
parent
21cb0ef437
commit
f0d6b9d1e8
@ -0,0 +1,15 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
ALTER TABLE comment_seers RENAME TO tmp_comment_seers;
|
||||||
|
|
||||||
|
CREATE TABLE comment_seers (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
comment_id INTEGER REFERENCES comments(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
UNIQUE (comment_id, user_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO comment_seers(id, comment_id, user_id)
|
||||||
|
SELECT id, comment_id, user_id
|
||||||
|
FROM tmp_comment_seers;
|
||||||
|
|
||||||
|
DROP TABLE tmp_comment_seers;
|
16
migrations/sqlite/2019-03-25-205630_fix-comment-seers/up.sql
Normal file
16
migrations/sqlite/2019-03-25-205630_fix-comment-seers/up.sql
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
ALTER TABLE comment_seers RENAME TO tmp_comment_seers;
|
||||||
|
|
||||||
|
CREATE TABLE comment_seers (
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
comment_id INTEGER REFERENCES comments(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
UNIQUE (comment_id, user_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO comment_seers(id, comment_id, user_id)
|
||||||
|
SELECT id, comment_id, user_id
|
||||||
|
FROM tmp_comment_seers
|
||||||
|
WHERE id NOT NULL;
|
||||||
|
|
||||||
|
DROP TABLE tmp_comment_seers;
|
Loading…
Reference in New Issue
Block a user