1 import * as Sequelize from 'sequelize'
2 import { join } from 'path'
3 import { HLS_STREAMING_PLAYLIST_DIRECTORY, WEBSERVER } from '@server/initializers/constants'
4 import { CONFIG } from '@server/initializers/config'
5 import { pathExists, stat, writeFile } from 'fs-extra'
6 import * as parseTorrent from 'parse-torrent'
7 import { createTorrentPromise } from '@server/helpers/webtorrent'
9 async function up (utils: {
10 transaction: Sequelize.Transaction,
11 queryInterface: Sequelize.QueryInterface,
12 sequelize: Sequelize.Sequelize,
17 type: Sequelize.INTEGER,
20 model: 'videoStreamingPlaylist',
26 await utils.queryInterface.addColumn('videoFile', 'videoStreamingPlaylistId', data)
31 type: Sequelize.INTEGER,
35 await utils.queryInterface.changeColumn('videoFile', 'videoId', data)
39 await utils.queryInterface.removeIndex('videoFile', 'video_file_video_id_resolution_fps')
43 const query = 'insert into "videoFile" ' +
44 '(resolution, size, "infoHash", "videoId", "createdAt", "updatedAt", fps, extname, "videoStreamingPlaylistId")' +
45 '(SELECT "videoFile".resolution, "videoFile".size, \'fake\', NULL, "videoFile"."createdAt", "videoFile"."updatedAt", "videoFile"."fps", ' +
46 '"videoFile".extname, "videoStreamingPlaylist".id FROM "videoStreamingPlaylist" ' +
47 'inner join video ON video.id = "videoStreamingPlaylist"."videoId" inner join "videoFile" ON "videoFile"."videoId" = video.id)'
49 await utils.sequelize.query(query, { transaction: utils.transaction })
53 function down (options) {
54 throw new Error('Not implemented.')