From 7aacaa76ec990f6b06f3f15a5666d103f68594f1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 19 Jun 2023 10:52:40 +0200 Subject: Fix registration notification error in client --- server/initializers/constants.ts | 2 +- .../migrations/0780-notification-registration.ts | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 server/initializers/migrations/0780-notification-registration.ts (limited to 'server/initializers') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 020ed68da..a92fd22d6 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -27,7 +27,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 775 +const LAST_MIGRATION_VERSION = 780 // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0780-notification-registration.ts b/server/initializers/migrations/0780-notification-registration.ts new file mode 100644 index 000000000..5f1e0d2ea --- /dev/null +++ b/server/initializers/migrations/0780-notification-registration.ts @@ -0,0 +1,30 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize +}): Promise { + const { transaction } = utils + + { + await utils.sequelize.query('DELETE FROM "userNotification" WHERE type = 20 AND "userRegistrationId" IS NULL', { transaction }) + } + + { + await utils.sequelize.query( + 'ALTER TABLE "userNotification" DROP CONSTRAINT "userNotification_userRegistrationId_fkey", ' + + 'ADD CONSTRAINT "userNotification_userRegistrationId_fkey" ' + + 'FOREIGN KEY ("userRegistrationId") REFERENCES "userRegistration" ("id") ON DELETE CASCADE ON UPDATE CASCADE', + { transaction }) + } +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3