0330-video-streaming-playlist.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import * as Sequelize from 'sequelize'
  2. async function up (utils: {
  3. transaction: Sequelize.Transaction
  4. queryInterface: Sequelize.QueryInterface
  5. sequelize: Sequelize.Sequelize
  6. }): Promise<void> {
  7. {
  8. const query = `
  9. CREATE TABLE IF NOT EXISTS "videoStreamingPlaylist"
  10. (
  11. "id" SERIAL,
  12. "type" INTEGER NOT NULL,
  13. "playlistUrl" VARCHAR(2000) NOT NULL,
  14. "p2pMediaLoaderInfohashes" VARCHAR(255)[] NOT NULL,
  15. "segmentsSha256Url" VARCHAR(255) NOT NULL,
  16. "videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
  17. "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
  18. "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
  19. PRIMARY KEY ("id")
  20. );`
  21. await utils.sequelize.query(query)
  22. }
  23. {
  24. const data = {
  25. type: Sequelize.INTEGER,
  26. allowNull: true,
  27. defaultValue: null
  28. }
  29. await utils.queryInterface.changeColumn('videoRedundancy', 'videoFileId', data)
  30. }
  31. {
  32. const query = 'ALTER TABLE "videoRedundancy" ADD COLUMN "videoStreamingPlaylistId" INTEGER NULL ' +
  33. 'REFERENCES "videoStreamingPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE'
  34. await utils.sequelize.query(query)
  35. }
  36. }
  37. function down (options) {
  38. throw new Error('Not implemented.')
  39. }
  40. export {
  41. up,
  42. down
  43. }