]>
Commit | Line | Data |
---|---|---|
764b1a14 C |
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 | } |