ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0720-session-ending-processed.ts 1.5 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. const { transaction } = utils
  9. {
  10. const data = {
  11. type: Sequelize.BOOLEAN,
  12. defaultValue: null,
  13. allowNull: true
  14. }
  15. await utils.queryInterface.addColumn('videoLiveSession', 'endingProcessed', data, { transaction })
  16. await utils.queryInterface.addColumn('videoLiveSession', 'saveReplay', data, { transaction })
  17. }
  18. {
  19. const query = `UPDATE "videoLiveSession" SET "saveReplay" = (
  20. SELECT "videoLive"."saveReplay" FROM "videoLive" WHERE "videoLive"."videoId" = "videoLiveSession"."liveVideoId"
  21. ) WHERE "videoLiveSession"."liveVideoId" IS NOT NULL`
  22. await utils.sequelize.query(query, { transaction })
  23. }
  24. {
  25. const query = `UPDATE "videoLiveSession" SET "saveReplay" = FALSE WHERE "saveReplay" IS NULL`
  26. await utils.sequelize.query(query, { transaction })
  27. }
  28. {
  29. const query = `UPDATE "videoLiveSession" SET "endingProcessed" = TRUE`
  30. await utils.sequelize.query(query, { transaction })
  31. }
  32. {
  33. const data = {
  34. type: Sequelize.BOOLEAN,
  35. defaultValue: null,
  36. allowNull: false
  37. }
  38. await utils.queryInterface.changeColumn('videoLiveSession', 'endingProcessed', data, { transaction })
  39. await utils.queryInterface.changeColumn('videoLiveSession', 'saveReplay', data, { transaction })
  40. }
  41. }
  42. function down (options) {
  43. throw new Error('Not implemented.')
  44. }
  45. export {
  46. up,
  47. down
  48. }