0150-avatar-cascade.ts 592 B

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