0295-video-file-extname.ts 974 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. await utils.queryInterface.renameColumn('videoFile', 'extname', 'extname_old')
  10. }
  11. {
  12. const data = {
  13. type: Sequelize.STRING,
  14. defaultValue: null,
  15. allowNull: true
  16. }
  17. await utils.queryInterface.addColumn('videoFile', 'extname', data)
  18. }
  19. {
  20. const query = 'UPDATE "videoFile" SET "extname" = "extname_old"::text'
  21. await utils.sequelize.query(query)
  22. }
  23. {
  24. const data = {
  25. type: Sequelize.STRING,
  26. defaultValue: null,
  27. allowNull: false
  28. }
  29. await utils.queryInterface.changeColumn('videoFile', 'extname', data)
  30. }
  31. {
  32. await utils.queryInterface.removeColumn('videoFile', 'extname_old')
  33. }
  34. }
  35. function down (options) {
  36. throw new Error('Not implemented.')
  37. }
  38. export {
  39. up,
  40. down
  41. }