0220-video-state.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // waitingTranscoding column
  8. {
  9. const data = {
  10. type: Sequelize.BOOLEAN,
  11. allowNull: true,
  12. defaultValue: null
  13. }
  14. await utils.queryInterface.addColumn('video', 'waitTranscoding', data)
  15. }
  16. {
  17. const query = 'UPDATE video SET "waitTranscoding" = false'
  18. await utils.sequelize.query(query)
  19. }
  20. {
  21. const data = {
  22. type: Sequelize.BOOLEAN,
  23. allowNull: false,
  24. defaultValue: null
  25. }
  26. await utils.queryInterface.changeColumn('video', 'waitTranscoding', data)
  27. }
  28. // state
  29. {
  30. const data = {
  31. type: Sequelize.INTEGER,
  32. allowNull: true,
  33. defaultValue: null
  34. }
  35. await utils.queryInterface.addColumn('video', 'state', data)
  36. }
  37. {
  38. // Published
  39. const query = 'UPDATE video SET "state" = 1'
  40. await utils.sequelize.query(query)
  41. }
  42. {
  43. const data = {
  44. type: Sequelize.INTEGER,
  45. allowNull: false,
  46. defaultValue: null
  47. }
  48. await utils.queryInterface.changeColumn('video', 'state', data)
  49. }
  50. }
  51. function down (options) {
  52. throw new Error('Not implemented.')
  53. }
  54. export { up, down }