0735-video-channel-sync-import-foreign-key.ts 768 B

1234567891011121314151617181920212223242526272829303132
  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. await utils.queryInterface.addColumn('videoImport', 'videoChannelSyncId', {
  9. type: Sequelize.INTEGER,
  10. defaultValue: null,
  11. allowNull: true,
  12. references: {
  13. model: 'videoChannelSync',
  14. key: 'id'
  15. },
  16. onUpdate: 'CASCADE',
  17. onDelete: 'SET NULL'
  18. }, { transaction: utils.transaction })
  19. }
  20. async function down (utils: {
  21. queryInterface: Sequelize.QueryInterface
  22. transaction: Sequelize.Transaction
  23. }) {
  24. await utils.queryInterface.dropTable('videoChannelSync', { transaction: utils.transaction })
  25. }
  26. export {
  27. up,
  28. down
  29. }