diff options
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 2 | ||||
-rw-r--r-- | server/initializers/migrations/0655-streaming-playlist-filenames.ts | 66 |
2 files changed, 67 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index ab59320eb..ee4503b2c 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 | ||
27 | const LAST_MIGRATION_VERSION = 650 | 27 | const LAST_MIGRATION_VERSION = 655 |
28 | 28 | ||
29 | // --------------------------------------------------------------------------- | 29 | // --------------------------------------------------------------------------- |
30 | 30 | ||
diff --git a/server/initializers/migrations/0655-streaming-playlist-filenames.ts b/server/initializers/migrations/0655-streaming-playlist-filenames.ts new file mode 100644 index 000000000..9172a22c4 --- /dev/null +++ b/server/initializers/migrations/0655-streaming-playlist-filenames.ts | |||
@@ -0,0 +1,66 @@ | |||
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 | for (const column of [ 'playlistUrl', 'segmentsSha256Url' ]) { | ||
11 | const data = { | ||
12 | type: Sequelize.STRING, | ||
13 | allowNull: true, | ||
14 | defaultValue: null | ||
15 | } | ||
16 | |||
17 | await utils.queryInterface.changeColumn('videoStreamingPlaylist', column, data) | ||
18 | } | ||
19 | } | ||
20 | |||
21 | { | ||
22 | await utils.sequelize.query( | ||
23 | `UPDATE "videoStreamingPlaylist" SET "playlistUrl" = NULL, "segmentsSha256Url" = NULL ` + | ||
24 | `WHERE "videoId" IN (SELECT id FROM video WHERE remote IS FALSE)` | ||
25 | ) | ||
26 | } | ||
27 | |||
28 | { | ||
29 | for (const column of [ 'playlistFilename', 'segmentsSha256Filename' ]) { | ||
30 | const data = { | ||
31 | type: Sequelize.STRING, | ||
32 | allowNull: true, | ||
33 | defaultValue: null | ||
34 | } | ||
35 | |||
36 | await utils.queryInterface.addColumn('videoStreamingPlaylist', column, data) | ||
37 | } | ||
38 | } | ||
39 | |||
40 | { | ||
41 | await utils.sequelize.query( | ||
42 | `UPDATE "videoStreamingPlaylist" SET "playlistFilename" = 'master.m3u8', "segmentsSha256Filename" = 'segments-sha256.json'` | ||
43 | ) | ||
44 | } | ||
45 | |||
46 | { | ||
47 | for (const column of [ 'playlistFilename', 'segmentsSha256Filename' ]) { | ||
48 | const data = { | ||
49 | type: Sequelize.STRING, | ||
50 | allowNull: false, | ||
51 | defaultValue: null | ||
52 | } | ||
53 | |||
54 | await utils.queryInterface.changeColumn('videoStreamingPlaylist', column, data) | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | |||
59 | function down (options) { | ||
60 | throw new Error('Not implemented.') | ||
61 | } | ||
62 | |||
63 | export { | ||
64 | up, | ||
65 | down | ||
66 | } | ||