From 7aacaa76ec990f6b06f3f15a5666d103f68594f1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 19 Jun 2023 10:52:40 +0200 Subject: [PATCH] Fix registration notification error in client --- server/initializers/constants.ts | 2 +- .../0780-notification-registration.ts | 30 +++++++++++++++++++ server/middlewares/rate-limiter.ts | 1 - 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 server/initializers/migrations/0780-notification-registration.ts 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 +} diff --git a/server/middlewares/rate-limiter.ts b/server/middlewares/rate-limiter.ts index 1eef8b360..0e936028c 100644 --- a/server/middlewares/rate-limiter.ts +++ b/server/middlewares/rate-limiter.ts @@ -45,5 +45,4 @@ export function buildRateLimiter (options: { function sendRateLimited (res: express.Response, options: RateLimitHandlerOptions) { return res.status(options.statusCode).send(options.message) - }