0150-avatar-cascade.ts 602 B

1234567891011121314151617181920212223242526272829
  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. await utils.queryInterface.removeConstraint('actor', 'actor_avatarId_fkey')
  8. await utils.queryInterface.addConstraint('actor', {
  9. fields: [ 'avatarId' ],
  10. type: 'foreign key',
  11. references: {
  12. table: 'avatar',
  13. field: 'id'
  14. },
  15. onDelete: 'set null',
  16. onUpdate: 'CASCADE'
  17. })
  18. }
  19. function down (options) {
  20. throw new Error('Not implemented.')
  21. }
  22. export {
  23. up,
  24. down
  25. }