From cdd6f649a230542f6561fd35eda5cd1d667e54c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Sat, 4 Jan 2025 00:48:52 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20flyway=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...__create_timetable_lecture_information.sql | 10 --- ...V110__create_lecture_information_table.sql | 8 --- ...ray_class_time_normalization_procedure.sql | 53 -------------- ...ray_class_time_normalization_procedure.sql | 71 ------------------- 4 files changed, 142 deletions(-) delete mode 100644 src/main/resources/db/migration/V109__create_timetable_lecture_information.sql delete mode 100644 src/main/resources/db/migration/V110__create_lecture_information_table.sql delete mode 100644 src/main/resources/db/migration/V111__add_array_class_time_normalization_procedure.sql delete mode 100644 src/main/resources/db/migration/V112__add_call_array_class_time_normalization_procedure.sql diff --git a/src/main/resources/db/migration/V109__create_timetable_lecture_information.sql b/src/main/resources/db/migration/V109__create_timetable_lecture_information.sql deleted file mode 100644 index 4deb817e0..000000000 --- a/src/main/resources/db/migration/V109__create_timetable_lecture_information.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE IF NOT EXISTS `koin`.`timetable_lecture_information` ( - `id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '고유 id', - `start_time` INT UNSIGNED NULL COMMENT '커스텀 강의 시작 시간', - `end_time` INT UNSIGNED NULL COMMENT '커스텀 강의 종료 시간', - `place` VARCHAR(255) NULL COMMENT '강의 장소', - `lecture_information_id` INT UNSIGNED NULL COMMENT 'lecture_information 고유 id', - `timetable_lecture_id` INT UNSIGNED NOT NULL COMMENT 'timetable_lecture 고유 id', - PRIMARY KEY (id), - INDEX(timetable_lecture_id) -) diff --git a/src/main/resources/db/migration/V110__create_lecture_information_table.sql b/src/main/resources/db/migration/V110__create_lecture_information_table.sql deleted file mode 100644 index 5751f428a..000000000 --- a/src/main/resources/db/migration/V110__create_lecture_information_table.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE IF NOT EXISTS `koin`.`lecture_information`( - `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '고유 id', - `lecture_id` int UNSIGNED NOT NULL COMMENT 'lecture 고유 id', - `start_time` int NULL COMMENT '정규 강의 시작 시간', - `end_time` int NULL COMMENT '정규 강의 마감 시간', - PRIMARY KEY (`id`), - index (`lecture_id`) -); diff --git a/src/main/resources/db/migration/V111__add_array_class_time_normalization_procedure.sql b/src/main/resources/db/migration/V111__add_array_class_time_normalization_procedure.sql deleted file mode 100644 index b5d5c6c64..000000000 --- a/src/main/resources/db/migration/V111__add_array_class_time_normalization_procedure.sql +++ /dev/null @@ -1,53 +0,0 @@ -DELIMITER $$ - -CREATE PROCEDURE array_class_time_normalization ( - IN_LECTURE_ID int unsigned -) -BEGIN - -- 변수 선언 - DECLARE IN_CLASS_TIME varchar(255); - DECLARE current_class_time int; - DECLARE prev_class_time int DEFAULT NULL; - DECLARE start_class_time int DEFAULT NULL; - DECLARE end_class_time int DEFAULT NULL; - DECLARE idx int DEFAULT 1; - DECLARE count int DEFAULT 1; - - -- class_time 가져오기 - SELECT class_time INTO IN_CLASS_TIME - FROM lectures - WHERE id = IN_LECTURE_ID; - - -- 대괄호 앞 뒤 삭제 - SET IN_CLASS_TIME = REPLACE(REPLACE(IN_CLASS_TIME, '[', ''), ']', ''); - - -- 강의 시간이 있는 경우에만 로직 실행 - IF LENGTH(IN_CLASS_TIME) != 0 THEN - -- 총 실행 횟수, (현재 길이 - 콤마를 없앴을 때의 길이 + 1 = 총 시간 개수) - SET count = LENGTH(IN_CLASS_TIME) - LENGTH(REPLACE(IN_CLASS_TIME, ',', '')) + 1; - WHILE idx <= count DO - -- 인덱스에 해당하는 시간 가져오기 - SET current_class_time = CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(IN_CLASS_TIME, ',', idx), ',', -1) AS UNSIGNED); - - -- 초기 시작 시간 설정 및 연속 시간 체크 - IF prev_class_time IS NULL OR current_class_time != prev_class_time + 1 THEN - IF start_class_time IS NOT NULL THEN - INSERT INTO lecture_information (lecture_id, start_time, end_time) VALUES (IN_LECTURE_ID, start_class_time, end_class_time); - END IF; - SET start_class_time = current_class_time; - END IF; - - -- 다음 시간 저장 - SET end_class_time = current_class_time; - SET prev_class_time = current_class_time; - SET idx = idx + 1; - END WHILE; - - -- 마지막 범위 추가 - IF start_class_time IS NOT NULL THEN - INSERT INTO lecture_information (lecture_id, start_time, end_time) VALUES (IN_LECTURE_ID, start_class_time, end_class_time); - END IF; - END IF; - -END $$ -DELIMITER ; diff --git a/src/main/resources/db/migration/V112__add_call_array_class_time_normalization_procedure.sql b/src/main/resources/db/migration/V112__add_call_array_class_time_normalization_procedure.sql deleted file mode 100644 index cbbc154ae..000000000 --- a/src/main/resources/db/migration/V112__add_call_array_class_time_normalization_procedure.sql +++ /dev/null @@ -1,71 +0,0 @@ -DELIMITER $$ - -CREATE PROCEDURE call_array_class_time_normalization( - IN_SEMESTER_DATE VARCHAR(10) -) -BEGIN - DECLARE done INT DEFAULT 0; - DECLARE lecture_id INT; - DECLARE flag INT DEFAULT 0; - - -- 커서 선언 - DECLARE cur CURSOR FOR - SELECT id FROM lectures - where semester_date = IN_SEMESTER_DATE; - - -- 종료 핸들러 정의 - DECLARE CONTINUE HANDLER FOR NOT FOUND SET flag = 1; - - -- 커서 열기 - OPEN cur; - - lecture_loop: LOOP - FETCH cur INTO lecture_id; -- 여기서 반환값이 없으면 에러가 발생 -> 이를 종료 핸들러가 캐치 - IF flag THEN -- 데이터가 없으면 루프 종료 - LEAVE lecture_loop; - END IF; - - CALL array_class_time_normalization(lecture_id); -END LOOP; - - -- 커서 닫기 - CLOSE cur; -END$$ - -DELIMITER ; - --- 2019 -CALL call_array_class_time_normalization("20191"); -CALL call_array_class_time_normalization("2019-여름"); -CALL call_array_class_time_normalization("20192"); -CALL call_array_class_time_normalization("2019-겨울"); - --- 2020 -CALL call_array_class_time_normalization("20201"); -CALL call_array_class_time_normalization("2020-여름"); -CALL call_array_class_time_normalization("20202"); -CALL call_array_class_time_normalization("2020-겨울"); - --- 2021 -CALL call_array_class_time_normalization("20211"); -CALL call_array_class_time_normalization("2021-여름"); -CALL call_array_class_time_normalization("20212"); -CALL call_array_class_time_normalization("2021-겨울"); - --- 2022 -CALL call_array_class_time_normalization("20221"); -CALL call_array_class_time_normalization("2022-여름"); -CALL call_array_class_time_normalization("20222"); -CALL call_array_class_time_normalization("2022-겨울"); - --- 2023 -CALL call_array_class_time_normalization("20231"); -CALL call_array_class_time_normalization("2023-여름"); -CALL call_array_class_time_normalization("20232"); -CALL call_array_class_time_normalization("2023-겨울"); - --- 2024 -CALL call_array_class_time_normalization("20241"); -CALL call_array_class_time_normalization("2024-여름"); -CALL call_array_class_time_normalization("20242"); -CALL call_array_class_time_normalization("2024-겨울");