diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-28 13:47:17 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-01-09 11:15:15 +0100 |
commit | e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241 (patch) | |
tree | c0986e91e6ed466af075ddac3c795894db4d0b85 /server/initializers/migrations | |
parent | cef534ed53e4518fe0acf581bfe880788d42fc36 (diff) | |
download | PeerTube-e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241.tar.gz PeerTube-e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241.tar.zst PeerTube-e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241.zip |
Add notification settings migration
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r-- | server/initializers/migrations/0315-user-notifications.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/server/initializers/migrations/0315-user-notifications.ts b/server/initializers/migrations/0315-user-notifications.ts new file mode 100644 index 000000000..2bd9c657d --- /dev/null +++ b/server/initializers/migrations/0315-user-notifications.ts | |||
@@ -0,0 +1,41 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction, | ||
5 | queryInterface: Sequelize.QueryInterface, | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | }): Promise<void> { | ||
8 | |||
9 | { | ||
10 | const query = ` | ||
11 | CREATE TABLE IF NOT EXISTS "userNotificationSetting" ("id" SERIAL, | ||
12 | "newVideoFromSubscription" INTEGER NOT NULL DEFAULT NULL, | ||
13 | "newCommentOnMyVideo" INTEGER NOT NULL DEFAULT NULL, | ||
14 | "videoAbuseAsModerator" INTEGER NOT NULL DEFAULT NULL, | ||
15 | "blacklistOnMyVideo" INTEGER NOT NULL DEFAULT NULL, | ||
16 | "userId" INTEGER REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
17 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
18 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
19 | PRIMARY KEY ("id")) | ||
20 | ` | ||
21 | await utils.sequelize.query(query) | ||
22 | } | ||
23 | |||
24 | { | ||
25 | const query = 'INSERT INTO "userNotificationSetting" ' + | ||
26 | '("newVideoFromSubscription", "newCommentOnMyVideo", "videoAbuseAsModerator", "blacklistOnMyVideo", ' + | ||
27 | '"userId", "createdAt", "updatedAt") ' + | ||
28 | '(SELECT 2, 2, 4, 4, id, NOW(), NOW() FROM "user")' | ||
29 | |||
30 | await utils.sequelize.query(query) | ||
31 | } | ||
32 | } | ||
33 | |||
34 | function down (options) { | ||
35 | throw new Error('Not implemented.') | ||
36 | } | ||
37 | |||
38 | export { | ||
39 | up, | ||
40 | down | ||
41 | } | ||