0630-banner.ts 1014 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.sequelize.query(`ALTER TABLE "avatar" RENAME to "actorImage"`)
  10. }
  11. {
  12. const data = {
  13. type: Sequelize.INTEGER,
  14. defaultValue: null,
  15. allowNull: true
  16. }
  17. await utils.queryInterface.addColumn('actorImage', 'type', data)
  18. }
  19. {
  20. await utils.sequelize.query(`UPDATE "actorImage" SET "type" = 1`)
  21. }
  22. {
  23. const data = {
  24. type: Sequelize.INTEGER,
  25. defaultValue: null,
  26. allowNull: false
  27. }
  28. await utils.queryInterface.changeColumn('actorImage', 'type', data)
  29. }
  30. {
  31. await utils.sequelize.query(
  32. `ALTER TABLE "actor" ADD COLUMN "bannerId" INTEGER REFERENCES "actorImage" ("id") ON DELETE SET NULL ON UPDATE CASCADE`
  33. )
  34. }
  35. }
  36. function down (options) {
  37. throw new Error('Not implemented.')
  38. }
  39. export {
  40. up,
  41. down
  42. }