Skip to content

Commit

Permalink
fix: add ON DELETE CASCADE to foreign key between GasValue and Activi…
Browse files Browse the repository at this point in the history
…tyValue to fix deletion issues

Signed-off-by: Evan Prodromou <[email protected]>
  • Loading branch information
evanp committed Dec 10, 2024
1 parent 63e9de4 commit f2df786
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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'
});
}
};

0 comments on commit f2df786

Please sign in to comment.