From 09054d20c0e70d851df83f7dcff12cd9f9fc0e9a Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Thu, 18 Jul 2024 13:54:36 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=B3=B5=ED=95=A9=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...8__relocate_composite_constraint_order.sql | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 data/db/migration/entity/V1.00.0.8__relocate_composite_constraint_order.sql diff --git a/data/db/migration/entity/V1.00.0.8__relocate_composite_constraint_order.sql b/data/db/migration/entity/V1.00.0.8__relocate_composite_constraint_order.sql new file mode 100644 index 000000000..a0ae6db95 --- /dev/null +++ b/data/db/migration/entity/V1.00.0.8__relocate_composite_constraint_order.sql @@ -0,0 +1,25 @@ +-- 복합 제약 조건을 제거 +ALTER TABLE MAPPING_MEMBER_WORKBOOK + DROP PRIMARY KEY; + +ALTER TABLE MAPPING_WORKBOOK_ARTICLE + DROP PRIMARY KEY; + +ALTER TABLE SUBSCRIPTION + DROP KEY target_member_id; + +ALTER TABLE SUBSCRIPTION + DROP KEY target_workbook_id; + +-- 복합 제약 조건을 추가 +ALTER TABLE MAPPING_MEMBER_WORKBOOK + ADD CONSTRAINT mapping_member_workbook_pk PRIMARY KEY (member_id, workbook_id); + +ALTER TABLE MAPPING_WORKBOOK_ARTICLE + ADD CONSTRAINT mapping_workbook_article_pk PRIMARY KEY (article_id, workbook_id); + +ALTER TABLE SUBSCRIPTION + ADD CONSTRAINT subscription_unique_member_id_target_member_id UNIQUE (member_id, target_member_id); + +ALTER TABLE SUBSCRIPTION + ADD CONSTRAINT subscription_unique_member_id_target_workbook_id UNIQUE (member_id, target_workbook_id);