]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/initializers/migrations/0450-streaming-playlist-files.ts
Fix remote actor creation date
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0450-streaming-playlist-files.ts
CommitLineData
d7a25329
C
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
a1587156
C
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
d7a25329
C
7 db: any
8}): Promise<void> {
9 {
10 const data = {
11 type: Sequelize.INTEGER,
12 allowNull: true,
13 references: {
14 model: 'videoStreamingPlaylist',
15 key: 'id'
16 },
17 onDelete: 'CASCADE'
18 }
19
20 await utils.queryInterface.addColumn('videoFile', 'videoStreamingPlaylistId', data)
21 }
22
23 {
24 const data = {
25 type: Sequelize.INTEGER,
26 allowNull: true
27 }
28
29 await utils.queryInterface.changeColumn('videoFile', 'videoId', data)
30 }
d441f2ed
C
31
32 {
33 await utils.queryInterface.removeIndex('videoFile', 'video_file_video_id_resolution_fps')
34 }
35
36 {
37 const query = 'insert into "videoFile" ' +
38 '(resolution, size, "infoHash", "videoId", "createdAt", "updatedAt", fps, extname, "videoStreamingPlaylistId")' +
a1587156
C
39 '(SELECT "videoFile".resolution, "videoFile".size, \'fake\', NULL, "videoFile"."createdAt", "videoFile"."updatedAt", ' +
40 '"videoFile"."fps", "videoFile".extname, "videoStreamingPlaylist".id FROM "videoStreamingPlaylist" ' +
d441f2ed
C
41 'inner join video ON video.id = "videoStreamingPlaylist"."videoId" inner join "videoFile" ON "videoFile"."videoId" = video.id)'
42
43 await utils.sequelize.query(query, { transaction: utils.transaction })
44 }
d7a25329
C
45}
46
47function down (options) {
48 throw new Error('Not implemented.')
49}
50
51export {
52 up,
53 down
54}