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/0525-abuse-messages.ts54
2 files changed, 55 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index a40a22395..ca6c2a7ff 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -23,7 +23,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
23 23
24// --------------------------------------------------------------------------- 24// ---------------------------------------------------------------------------
25 25
26const LAST_MIGRATION_VERSION = 520 26const LAST_MIGRATION_VERSION = 525
27 27
28// --------------------------------------------------------------------------- 28// ---------------------------------------------------------------------------
29 29
diff --git a/server/initializers/migrations/0525-abuse-messages.ts b/server/initializers/migrations/0525-abuse-messages.ts
new file mode 100644
index 000000000..c8fd7cbcf
--- /dev/null
+++ b/server/initializers/migrations/0525-abuse-messages.ts
@@ -0,0 +1,54 @@
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 await utils.sequelize.query(`
9 CREATE TABLE IF NOT EXISTS "abuseMessage" (
10 "id" serial,
11 "message" text NOT NULL,
12 "byModerator" boolean NOT NULL,
13 "accountId" integer REFERENCES "account" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
14 "abuseId" integer NOT NULL REFERENCES "abuse" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
15 "createdAt" timestamp WITH time zone NOT NULL,
16 "updatedAt" timestamp WITH time zone NOT NULL,
17 PRIMARY KEY ("id")
18 );
19 `)
20
21 const notificationSettingColumns = [ 'abuseStateChange', 'abuseNewMessage' ]
22
23 for (const column of notificationSettingColumns) {
24 const data = {
25 type: Sequelize.INTEGER,
26 defaultValue: null,
27 allowNull: true
28 }
29 await utils.queryInterface.addColumn('userNotificationSetting', column, data)
30 }
31
32 {
33 const query = 'UPDATE "userNotificationSetting" SET "abuseStateChange" = 3, "abuseNewMessage" = 3'
34 await utils.sequelize.query(query)
35 }
36
37 for (const column of notificationSettingColumns) {
38 const data = {
39 type: Sequelize.INTEGER,
40 defaultValue: null,
41 allowNull: false
42 }
43 await utils.queryInterface.changeColumn('userNotificationSetting', column, data)
44 }
45}
46
47function down (options) {
48 throw new Error('Not implemented.')
49}
50
51export {
52 up,
53 down
54}