0655-streaming-playlist-filenames.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import * as Sequelize from 'sequelize'
  2. async function up (utils: {
  3. transaction: Sequelize.Transaction
  4. queryInterface: Sequelize.QueryInterface
  5. sequelize: Sequelize.Sequelize
  6. db: any
  7. }): Promise<void> {
  8. {
  9. for (const column of [ 'playlistUrl', 'segmentsSha256Url' ]) {
  10. const data = {
  11. type: Sequelize.STRING,
  12. allowNull: true,
  13. defaultValue: null
  14. }
  15. await utils.queryInterface.changeColumn('videoStreamingPlaylist', column, data)
  16. }
  17. }
  18. {
  19. await utils.sequelize.query(
  20. `UPDATE "videoStreamingPlaylist" SET "playlistUrl" = NULL, "segmentsSha256Url" = NULL ` +
  21. `WHERE "videoId" IN (SELECT id FROM video WHERE remote IS FALSE)`
  22. )
  23. }
  24. {
  25. for (const column of [ 'playlistFilename', 'segmentsSha256Filename' ]) {
  26. const data = {
  27. type: Sequelize.STRING,
  28. allowNull: true,
  29. defaultValue: null
  30. }
  31. await utils.queryInterface.addColumn('videoStreamingPlaylist', column, data)
  32. }
  33. }
  34. {
  35. await utils.sequelize.query(
  36. `UPDATE "videoStreamingPlaylist" SET "playlistFilename" = 'master.m3u8', "segmentsSha256Filename" = 'segments-sha256.json'`
  37. )
  38. }
  39. {
  40. for (const column of [ 'playlistFilename', 'segmentsSha256Filename' ]) {
  41. const data = {
  42. type: Sequelize.STRING,
  43. allowNull: false,
  44. defaultValue: null
  45. }
  46. await utils.queryInterface.changeColumn('videoStreamingPlaylist', column, data)
  47. }
  48. }
  49. }
  50. function down (options) {
  51. throw new Error('Not implemented.')
  52. }
  53. export {
  54. up,
  55. down
  56. }