From ddacfc34e9e89f2d6554065abf2e6af430498d18 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Fri, 2 Aug 2024 12:52:27 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix=20:=20unique=20=EC=A0=9C=EC=95=BD=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 소프트 삭제로 인한 삭제 후 친구, 친구 요청 시 오류 발생으로 삭제 --- .../resources/db/migration/V34__drop_unique_owner_friend.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 backend/core/src/main/resources/db/migration/V34__drop_unique_owner_friend.sql diff --git a/backend/core/src/main/resources/db/migration/V34__drop_unique_owner_friend.sql b/backend/core/src/main/resources/db/migration/V34__drop_unique_owner_friend.sql new file mode 100644 index 000000000..d73537a5b --- /dev/null +++ b/backend/core/src/main/resources/db/migration/V34__drop_unique_owner_friend.sql @@ -0,0 +1,2 @@ +ALTER TABLE friend_invite DROP INDEX unique_owner_friend_pair +ALTER TABLE member_friend DROP INDEX unique_owner_friend_relation \ No newline at end of file From 59ce6fe9fe94cd9db263025fba217e5423af81a7 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Fri, 2 Aug 2024 13:16:12 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix=20:=20=EC=99=B8=EB=9E=98=20=ED=82=A4=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=ED=9B=84=20=EC=9C=A0=EB=8B=88=ED=81=AC=20?= =?UTF-8?q?=ED=82=A4=20=EC=82=AD=EC=A0=9C=20=ED=9B=84=20=EC=99=B8=EB=9E=98?= =?UTF-8?q?=20=ED=82=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 외래 키 때문에 유니크 키를 삭제할 수 없는 현상 --- .../V34__drop_unique_owner_friend.sql | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/backend/core/src/main/resources/db/migration/V34__drop_unique_owner_friend.sql b/backend/core/src/main/resources/db/migration/V34__drop_unique_owner_friend.sql index d73537a5b..f51be58a5 100644 --- a/backend/core/src/main/resources/db/migration/V34__drop_unique_owner_friend.sql +++ b/backend/core/src/main/resources/db/migration/V34__drop_unique_owner_friend.sql @@ -1,2 +1,29 @@ -ALTER TABLE friend_invite DROP INDEX unique_owner_friend_pair -ALTER TABLE member_friend DROP INDEX unique_owner_friend_relation \ No newline at end of file +-- friend_invite 외래 키 삭제 -> 유니크 키 삭제 -> 외래 키 추가 +ALTER TABLE friend_invite + DROP CONSTRAINT fk_friend_invite_owner_id; + +ALTER TABLE friend_invite + DROP CONSTRAINT fk_friend_invite_friend_id; + +ALTER TABLE friend_invite DROP KEY unique_owner_friend_pair; + +ALTER TABLE friend_invite + ADD CONSTRAINT fk_friend_invite_owner_id FOREIGN KEY (owner_id) REFERENCES member (member_id); + +ALTER TABLE friend_invite + ADD CONSTRAINT fk_friend_invite_friend_id FOREIGN KEY (friend_id) REFERENCES member (member_id); + +-- member_friend 외래 키 삭제 -> 유니크 키 삭제 -> 외래 키 추가 +ALTER TABLE member_friend + DROP CONSTRAINT fk_member_friend_owner_id; + +ALTER TABLE member_friend + DROP CONSTRAINT fk_member_friend_friend_id; + +ALTER TABLE member_friend DROP KEY unique_owner_friend_relation; + +ALTER TABLE member_friend + ADD CONSTRAINT fk_member_friend_owner_id FOREIGN KEY (owner_id) REFERENCES member (member_id); + +ALTER TABLE member_friend + ADD CONSTRAINT fk_member_friend_friend_id FOREIGN KEY (friend_id) REFERENCES member (member_id); \ No newline at end of file