diff --git a/app/migrations/20241210173228-gasvalue-activityvalue-on-delete-cascade.cjs b/app/migrations/20241210173228-gasvalue-activityvalue-on-delete-cascade.cjs new file mode 100644 index 000000000..aaee7252d --- /dev/null +++ b/app/migrations/20241210173228-gasvalue-activityvalue-on-delete-cascade.cjs @@ -0,0 +1,36 @@ + +"use strict"; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + + async up(queryInterface, Sequelize) { + await queryInterface.removeConstraint('GasValue', 'FK_GasValue_activity_value_id'); + await queryInterface.addConstraint('GasValue', { + fields: ['activity_value_id'], + type: 'foreign key', + name: 'FK_GasValue_activity_value_id', + references: { + table: 'ActivityValue', + field: 'id' + }, + onDelete: 'CASCADE', + onUpdate: 'CASCADE' + }); + }, + + async down(queryInterface, Sequelize) { + await queryInterface.removeConstraint('GasValue', 'FK_GasValue_activity_value_id'); + await queryInterface.addConstraint('GasValue', { + fields: ['activity_value_id'], + type: 'foreign key', + name: 'FK_GasValue_activity_value_id', + references: { + table: 'ActivityValue', + field: 'id' + }, + onDelete: 'NO ACTION', + onUpdate: 'NO ACTION' + }); + } +};