Skip to content

Commit

Permalink
Merge pull request #428 from Open-Earth-Foundation/fix/disconnect-source
Browse files Browse the repository at this point in the history
fix(db): not being able to disconnect source because of incorrect foreign key constraints
  • Loading branch information
lemilonkh authored Apr 8, 2024
2 parents 09fb425 + 61ee19d commit 369f0eb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/migrations/20240408115847-inventory-value-cascade.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface) {
return queryInterface.sequelize.query(`
BEGIN;
ALTER TABLE "GasValue" DROP CONSTRAINT "GasValue_emissions_factor_id_fkey";
ALTER TABLE "GasValue" DROP CONSTRAINT "GasValue_inventory_value_id_fkey";
COMMIT;
`);
},

async down(queryInterface) {
return queryInterface.sequelize.query(`
BEGIN;
ALTER TABLE "GasValue" ADD CONSTRAINT "GasValue_emissions_factor_id_fkey" FOREIGN KEY (emissions_factor_id) REFERENCES "EmissionsFactor"(id);
ALTER TABLE "GasValue" ADD CONSTRAINT "GasValue_inventory_value_id_fkey" FOREIGN KEY (inventory_value_id) REFERENCES "InventoryValue"(id);
COMMIT;
`);
},
};

0 comments on commit 369f0eb

Please sign in to comment.