From 61ee19d3030876fae4d7d56be96dd37040f86fe6 Mon Sep 17 00:00:00 2001 From: Milan Gruner Date: Mon, 8 Apr 2024 14:12:17 +0200 Subject: [PATCH] fix(db): remove incorrect additional constraints on GasValue table --- ...20240408115847-inventory-value-cascade.cjs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/migrations/20240408115847-inventory-value-cascade.cjs diff --git a/app/migrations/20240408115847-inventory-value-cascade.cjs b/app/migrations/20240408115847-inventory-value-cascade.cjs new file mode 100644 index 000000000..1deabc1d7 --- /dev/null +++ b/app/migrations/20240408115847-inventory-value-cascade.cjs @@ -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; + `); + }, +};