From cf941d2f000720fc36e1cf1a825d91f546b8d4d2 Mon Sep 17 00:00:00 2001 From: George Spanos Date: Tue, 21 Nov 2023 12:55:44 +0200 Subject: [PATCH] fix(migrations) - cascade delete trades on user remove --- .../src/db/migrations/4_pokemon_trade_cascade_delete.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 catchemall/web-api/src/db/migrations/4_pokemon_trade_cascade_delete.sql diff --git a/catchemall/web-api/src/db/migrations/4_pokemon_trade_cascade_delete.sql b/catchemall/web-api/src/db/migrations/4_pokemon_trade_cascade_delete.sql new file mode 100644 index 0000000..194336e --- /dev/null +++ b/catchemall/web-api/src/db/migrations/4_pokemon_trade_cascade_delete.sql @@ -0,0 +1,8 @@ +ALTER TABLE pokemon_trade +DROP CONSTRAINT fk_initiator_user_pokemon_id; + +ALTER TABLE pokemon_trade +DROP CONSTRAINT fk_responder_user_pokemon_id; + +ALTER TABLE pokemon_trade ADD CONSTRAINT fk_initiator_user_pokemon_id FOREIGN KEY (initiator_user_pokemon_id) REFERENCES "user_pokemon" (id) ON DELETE CASCADE; +ALTER TABLE pokemon_trade ADD CONSTRAINT fk_responder_user_pokemon_id FOREIGN KEY (responder_user_pokemon_id) REFERENCES "user_pokemon" (id) ON DELETE CASCADE;