diff options
Diffstat (limited to 'server/initializers/migrations/0615-latest-versions-notification-settings.ts')
-rw-r--r-- | server/initializers/migrations/0615-latest-versions-notification-settings.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/server/initializers/migrations/0615-latest-versions-notification-settings.ts b/server/initializers/migrations/0615-latest-versions-notification-settings.ts new file mode 100644 index 000000000..86bf56009 --- /dev/null +++ b/server/initializers/migrations/0615-latest-versions-notification-settings.ts | |||
@@ -0,0 +1,44 @@ | |||
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 | db: any | ||
8 | }): Promise<void> { | ||
9 | { | ||
10 | const notificationSettingColumns = [ 'newPeerTubeVersion', 'newPluginVersion' ] | ||
11 | |||
12 | for (const column of notificationSettingColumns) { | ||
13 | const data = { | ||
14 | type: Sequelize.INTEGER, | ||
15 | defaultValue: null, | ||
16 | allowNull: true | ||
17 | } | ||
18 | await utils.queryInterface.addColumn('userNotificationSetting', column, data) | ||
19 | } | ||
20 | |||
21 | { | ||
22 | const query = 'UPDATE "userNotificationSetting" SET "newPeerTubeVersion" = 3, "newPluginVersion" = 1' | ||
23 | await utils.sequelize.query(query) | ||
24 | } | ||
25 | |||
26 | for (const column of notificationSettingColumns) { | ||
27 | const data = { | ||
28 | type: Sequelize.INTEGER, | ||
29 | defaultValue: null, | ||
30 | allowNull: false | ||
31 | } | ||
32 | await utils.queryInterface.changeColumn('userNotificationSetting', column, data) | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | |||
37 | function down (options) { | ||
38 | throw new Error('Not implemented.') | ||
39 | } | ||
40 | |||
41 | export { | ||
42 | up, | ||
43 | down | ||
44 | } | ||