mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-22 03:21:01 +00:00
Fix issue with sqlite migrations for comment_seers (#503)
This commit is contained in:
parent
21cb0ef437
commit
f0d6b9d1e8
2 changed files with 31 additions and 0 deletions
|
@ -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 a new issue