diff options
Diffstat (limited to 'server/initializers/migrations/0780-notification-registration.ts')
-rw-r--r-- | server/initializers/migrations/0780-notification-registration.ts | 30 |
1 files changed, 30 insertions, 0 deletions
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async 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 | |||
23 | function down (options) { | ||
24 | throw new Error('Not implemented.') | ||
25 | } | ||
26 | |||
27 | export { | ||
28 | up, | ||
29 | down | ||
30 | } | ||