aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-12-28 13:47:17 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-01-09 11:15:15 +0100
commite8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241 (patch)
treec0986e91e6ed466af075ddac3c795894db4d0b85 /server/initializers
parentcef534ed53e4518fe0acf581bfe880788d42fc36 (diff)
downloadPeerTube-e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241.tar.gz
PeerTube-e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241.tar.zst
PeerTube-e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241.zip
Add notification settings migration
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0315-user-notifications.ts41
2 files changed, 42 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index fcfaf71a0..91e74f6c7 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -16,7 +16,7 @@ let config: IConfig = require('config')
16 16
17// --------------------------------------------------------------------------- 17// ---------------------------------------------------------------------------
18 18
19const LAST_MIGRATION_VERSION = 310 19const LAST_MIGRATION_VERSION = 315
20 20
21// --------------------------------------------------------------------------- 21// ---------------------------------------------------------------------------
22 22
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 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction,
5 queryInterface: Sequelize.QueryInterface,
6 sequelize: Sequelize.Sequelize
7}): Promise<void> {
8
9 {
10 const query = `
11CREATE 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,
19PRIMARY 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
34function down (options) {
35 throw new Error('Not implemented.')
36}
37
38export {
39 up,
40 down
41}