1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

fix: add cascade query inside create table for splash

This commit is contained in:
Youssef 2021-11-12 13:01:56 +01:00
parent 0199d1f211
commit 16429fcf9a
2 changed files with 3 additions and 18 deletions

View File

@ -4,11 +4,12 @@ exports.up = function (db, cb) {
db.runSql( db.runSql(
` `
CREATE TABLE IF NOT EXISTS user_splash CREATE TABLE IF NOT EXISTS user_splash
(user_id INTEGER NOT NULL references users (id), (user_id INTEGER NOT NULL references users (id) ON DELETE CASCADE,
splash_id TEXT, splash_id TEXT,
seen BOOLEAN NOT NULL DEFAULT false, seen BOOLEAN NOT NULL DEFAULT false,
PRIMARY KEY (user_id, splash_id)); PRIMARY KEY (user_id, splash_id));
CREATE INDEX user_splash_user_id_idx ON user_splash (user_id);`, CREATE INDEX user_splash_user_id_idx ON user_splash (user_id);
`,
cb, cb,
); );
}; };

View File

@ -1,16 +0,0 @@
exports.up = function (db, cb) {
db.runSql(
`
ALTER TABLE user_splash DROP CONSTRAINT user_splash_user_id_fkey;
ALTER TABLE user_splash
ADD CONSTRAINT user_splash_user_id_fkey
FOREIGN KEY (user_id)
REFERENCES users(id) ON DELETE CASCADE;
`,
cb,
);
};
exports.down = function (db, cb) {
db.runSql('', cb);
};