From 764b1a14fc494f2cfd7ea590d2f07b01df65c7ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 23 Jul 2021 11:20:00 +0200 Subject: Use random names for VOD HLS playlists --- .../0655-streaming-playlist-filenames.ts | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 server/initializers/migrations/0655-streaming-playlist-filenames.ts (limited to 'server/initializers/migrations/0655-streaming-playlist-filenames.ts') 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 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize + db: any +}): Promise { + { + for (const column of [ 'playlistUrl', 'segmentsSha256Url' ]) { + const data = { + type: Sequelize.STRING, + allowNull: true, + defaultValue: null + } + + await utils.queryInterface.changeColumn('videoStreamingPlaylist', column, data) + } + } + + { + await utils.sequelize.query( + `UPDATE "videoStreamingPlaylist" SET "playlistUrl" = NULL, "segmentsSha256Url" = NULL ` + + `WHERE "videoId" IN (SELECT id FROM video WHERE remote IS FALSE)` + ) + } + + { + for (const column of [ 'playlistFilename', 'segmentsSha256Filename' ]) { + const data = { + type: Sequelize.STRING, + allowNull: true, + defaultValue: null + } + + await utils.queryInterface.addColumn('videoStreamingPlaylist', column, data) + } + } + + { + await utils.sequelize.query( + `UPDATE "videoStreamingPlaylist" SET "playlistFilename" = 'master.m3u8', "segmentsSha256Filename" = 'segments-sha256.json'` + ) + } + + { + for (const column of [ 'playlistFilename', 'segmentsSha256Filename' ]) { + const data = { + type: Sequelize.STRING, + allowNull: false, + defaultValue: null + } + + await utils.queryInterface.changeColumn('videoStreamingPlaylist', column, data) + } + } +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3