From e8d246d5267ea8b6b3114d4bcf4f34fe5f3a5241 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 Dec 2018 13:47:17 +0100 Subject: Add notification settings migration --- server/initializers/constants.ts | 2 +- .../migrations/0315-user-notifications.ts | 41 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 server/initializers/migrations/0315-user-notifications.ts (limited to 'server/initializers') 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') // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 310 +const LAST_MIGRATION_VERSION = 315 // --------------------------------------------------------------------------- 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 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction, + queryInterface: Sequelize.QueryInterface, + sequelize: Sequelize.Sequelize +}): Promise { + + { + const query = ` +CREATE TABLE IF NOT EXISTS "userNotificationSetting" ("id" SERIAL, +"newVideoFromSubscription" INTEGER NOT NULL DEFAULT NULL, +"newCommentOnMyVideo" INTEGER NOT NULL DEFAULT NULL, +"videoAbuseAsModerator" INTEGER NOT NULL DEFAULT NULL, +"blacklistOnMyVideo" INTEGER NOT NULL DEFAULT NULL, +"userId" INTEGER REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE, +"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, +"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, +PRIMARY KEY ("id")) +` + await utils.sequelize.query(query) + } + + { + const query = 'INSERT INTO "userNotificationSetting" ' + + '("newVideoFromSubscription", "newCommentOnMyVideo", "videoAbuseAsModerator", "blacklistOnMyVideo", ' + + '"userId", "createdAt", "updatedAt") ' + + '(SELECT 2, 2, 4, 4, id, NOW(), NOW() FROM "user")' + + await utils.sequelize.query(query) + } +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3