Skip to content

Commit

Permalink
Update foreign key constraints to cascade on delete (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy authored Oct 2, 2024
1 parent fc822e3 commit dcc6b40
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions migrations/1727852225583_scenario-foreing-keys.js
Original file line number Diff line number Diff line change
@@ -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",
},
})

}

0 comments on commit dcc6b40

Please sign in to comment.