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/0720-session-ending-processed.ts56
2 files changed, 57 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 8cb4d5f4a..e3f7ceb4a 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
24 24
25// --------------------------------------------------------------------------- 25// ---------------------------------------------------------------------------
26 26
27const LAST_MIGRATION_VERSION = 715 27const LAST_MIGRATION_VERSION = 720
28 28
29// --------------------------------------------------------------------------- 29// ---------------------------------------------------------------------------
30 30
diff --git a/server/initializers/migrations/0720-session-ending-processed.ts b/server/initializers/migrations/0720-session-ending-processed.ts
new file mode 100644
index 000000000..74ffb39a0
--- /dev/null
+++ b/server/initializers/migrations/0720-session-ending-processed.ts
@@ -0,0 +1,56 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7 db: any
8}): Promise<void> {
9 const { transaction } = utils
10
11 {
12 const data = {
13 type: Sequelize.BOOLEAN,
14 defaultValue: null,
15 allowNull: true
16 }
17 await utils.queryInterface.addColumn('videoLiveSession', 'endingProcessed', data, { transaction })
18 await utils.queryInterface.addColumn('videoLiveSession', 'saveReplay', data, { transaction })
19 }
20
21 {
22 const query = `UPDATE "videoLiveSession" SET "saveReplay" = (
23 SELECT "videoLive"."saveReplay" FROM "videoLive" WHERE "videoLive"."videoId" = "videoLiveSession"."liveVideoId"
24 ) WHERE "videoLiveSession"."liveVideoId" IS NOT NULL`
25 await utils.sequelize.query(query, { transaction })
26 }
27
28 {
29 const query = `UPDATE "videoLiveSession" SET "saveReplay" = FALSE WHERE "saveReplay" IS NULL`
30 await utils.sequelize.query(query, { transaction })
31 }
32
33 {
34 const query = `UPDATE "videoLiveSession" SET "endingProcessed" = TRUE`
35 await utils.sequelize.query(query, { transaction })
36 }
37
38 {
39 const data = {
40 type: Sequelize.BOOLEAN,
41 defaultValue: null,
42 allowNull: false
43 }
44 await utils.queryInterface.changeColumn('videoLiveSession', 'endingProcessed', data, { transaction })
45 await utils.queryInterface.changeColumn('videoLiveSession', 'saveReplay', data, { transaction })
46 }
47}
48
49function down (options) {
50 throw new Error('Not implemented.')
51}
52
53export {
54 up,
55 down
56}