From 45562c834c44dd02969b7343c5064b5635d2d043 Mon Sep 17 00:00:00 2001 From: donghoony Date: Wed, 22 Jan 2025 22:50:03 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Flyway=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20DDL=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/db/migration/V4__template_association.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/resources/db/migration/V4__template_association.sql b/backend/src/main/resources/db/migration/V4__template_association.sql index 349e4aed1..440768ed9 100644 --- a/backend/src/main/resources/db/migration/V4__template_association.sql +++ b/backend/src/main/resources/db/migration/V4__template_association.sql @@ -6,9 +6,9 @@ ALTER TABLE question ADD COLUMN section_id BIGINT; ALTER TABLE question ADD COLUMN option_group_id BIGINT; -- 기존 테이블의 데이터를 새로운 테이블로 이동 -UPDATE question q SET section_id = sq.section_id FROM section_question sq WHERE q.id = sq.question_id; -UPDATE section s SET template_id = st.template_id FROM template_section st WHERE s.id = st.section_id; -UPDATE question q SET option_group_id = og.id FROM option_group og WHERE q.id = og.question_id; +UPDATE question q JOIN section_question sq ON q.id = sq.question_id SET q.section_id = sq.section_id; +UPDATE section s JOIN template_section st ON s.id = st.section_id SET s.template_id = st.template_id; +UPDATE question q JOIN option_group og ON q.id = og.question_id SET q.option_group_id = og.id; -- FK 관계 설정 ALTER TABLE section ADD CONSTRAINT section_fk_template_id FOREIGN KEY (template_id) REFERENCES template (id);