aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0780-notification-registration.ts30
2 files changed, 31 insertions, 1 deletions
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'
27 27
28// --------------------------------------------------------------------------- 28// ---------------------------------------------------------------------------
29 29
30const LAST_MIGRATION_VERSION = 775 30const LAST_MIGRATION_VERSION = 780
31 31
32// --------------------------------------------------------------------------- 32// ---------------------------------------------------------------------------
33 33
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 @@
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 const { transaction } = utils
9
10 {
11 await utils.sequelize.query('DELETE FROM "userNotification" WHERE type = 20 AND "userRegistrationId" IS NULL', { transaction })
12 }
13
14 {
15 await utils.sequelize.query(
16 'ALTER TABLE "userNotification" DROP CONSTRAINT "userNotification_userRegistrationId_fkey", ' +
17 'ADD CONSTRAINT "userNotification_userRegistrationId_fkey" ' +
18 'FOREIGN KEY ("userRegistrationId") REFERENCES "userRegistration" ("id") ON DELETE CASCADE ON UPDATE CASCADE',
19 { transaction })
20 }
21}
22
23function down (options) {
24 throw new Error('Not implemented.')
25}
26
27export {
28 up,
29 down
30}