]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/initializers/migrations/0315-user-notifications.ts
Add notification settings migration
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0315-user-notifications.ts
CommitLineData
e8d246d5
C
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}