From 6d57a7d27ff892bfd8f6aefbec0bdce36746b1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:18:20 +0200 Subject: [PATCH] Update foreign key constraints to cascade on delete --- .../1727852225583_scenario-foreing-keys.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 migrations/1727852225583_scenario-foreing-keys.js diff --git a/migrations/1727852225583_scenario-foreing-keys.js b/migrations/1727852225583_scenario-foreing-keys.js new file mode 100644 index 0000000..f85bf32 --- /dev/null +++ b/migrations/1727852225583_scenario-foreing-keys.js @@ -0,0 +1,24 @@ + +exports.up = (pgm) => { + pgm.dropConstraint({ schema: "jtl", name: "notifications" }, "notifications_scenario_id_fkey") + pgm.addConstraint({ schema: "jtl", name: "notifications" }, "notifications_scenario_id_fkey", { + foreignKeys: { + columns: "scenario_id", + references: { + schema: "jtl", name: "scenario", column: "id", + }, + onDelete: "CASCADE", + }, + }) + pgm.dropConstraint({ schema: "jtl", name: "scenario_share_tokens" }, "scenario_share_tokens_scenario_id_fkey") + pgm.addConstraint({ schema: "jtl", name: "scenario_share_tokens" }, "scenario_share_tokens_scenario_id_fkey", { + foreignKeys: { + columns: "scenario_id", + references: { + schema: "jtl", name: "scenario", column: "id", + }, + onDelete: "CASCADE", + }, + }) + +}