0060-video-file.ts 960 B

12345678910111213141516171819202122232425262728293031323334
  1. import * as Sequelize from 'sequelize'
  2. import * as Promise from 'bluebird'
  3. function up (utils: {
  4. transaction: Sequelize.Transaction,
  5. queryInterface: Sequelize.QueryInterface,
  6. sequelize: Sequelize.Sequelize,
  7. db: any
  8. }): Promise<void> {
  9. const q = utils.queryInterface
  10. const query = 'INSERT INTO "VideoFiles" ("videoId", "resolution", "size", "extname", "infoHash", "createdAt", "updatedAt") ' +
  11. 'SELECT "id" AS "videoId", 0 AS "resolution", 0 AS "size", ' +
  12. '"extname"::"text"::"enum_VideoFiles_extname" as "extname", "infoHash", "createdAt", "updatedAt" ' +
  13. 'FROM "Videos"'
  14. return utils.db.VideoFile.sync()
  15. .then(() => utils.sequelize.query(query))
  16. .then(() => {
  17. return q.removeColumn('Videos', 'extname')
  18. })
  19. .then(() => {
  20. return q.removeColumn('Videos', 'infoHash')
  21. })
  22. }
  23. function down (options) {
  24. throw new Error('Not implemented.')
  25. }
  26. export {
  27. up,
  28. down
  29. }