aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0720-session-ending-processed.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-22 15:22:21 +0200
committerChocobozzz <me@florianbigard.com>2022-07-22 15:22:21 +0200
commitc8fa571f32b10c083fab07f28d2ef55895ef40af (patch)
treefd50f90cc7643333984ed3b19f6a06f2e9f54feb /server/initializers/migrations/0720-session-ending-processed.ts
parenta77c5ff3622ab75d0c22241d0ef72053deaa7926 (diff)
downloadPeerTube-c8fa571f32b10c083fab07f28d2ef55895ef40af.tar.gz
PeerTube-c8fa571f32b10c083fab07f28d2ef55895ef40af.tar.zst
PeerTube-c8fa571f32b10c083fab07f28d2ef55895ef40af.zip
Clearer live session
Get the save replay setting when the session started to prevent inconsistent behaviour when the setting changed before the session was processed by the live ending job Display more information about the potential session replay in live modal information
Diffstat (limited to 'server/initializers/migrations/0720-session-ending-processed.ts')
-rw-r--r--server/initializers/migrations/0720-session-ending-processed.ts56
1 files changed, 56 insertions, 0 deletions
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}