-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix : coopshop 기존 데이터가 없는 로컬에서도 동작하도록 flyway 쿼리 수정 #957
Changes from 3 commits
87cfc67
8c098f0
6a45e91
8124d2f
2c8d4d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,68 @@ | ||
ALTER TABLE coop_semester AUTO_INCREMENT = 1; | ||
ALTER TABLE coop_shop AUTO_INCREMENT = 2; | ||
ALTER TABLE coop_opens AUTO_INCREMENT = 7; | ||
|
||
insert into `coop_semester` (`semester`, `from_date`, `to_date`, `is_applied`) | ||
values ('24-2학기', '2024-09-02', '2024-12-20', 1); | ||
|
||
INSERT INTO `coop_shop` (`name`, `phone`, `location`, `remarks`, `semester_id`) | ||
VALUES | ||
('복지관식당', '041-560-1778', 'NULL', '능수관', 1), | ||
('대즐', '041-560-1779', '복지관 1층', '배달 서비스, 공·일요일 미운영', 1), | ||
('서점', '041-560-1756', '복지관 1층', '점심시간 12:00 - 13:00', 1), | ||
('세탁소', '041-552-1489', '학생회관 2층', 'NULL', 1), | ||
('복사실', '041-560-1093', '학생회관 2층', '점심시간 11:30 - 12:30', 1), | ||
('복지관 참빛관 편의점', '041-560-1093', '복지관 1층, 참빛관 1층', '복지관 임시운영 별도공지', 1), | ||
('미용실', '041-560-1769', '학생회관 1층', '예약제운영', 1), | ||
('오락실', '041-560-1472', '학생회관 1층', 'NULL', 1); | ||
|
||
update `coop_shop` set `semester_id` = 1 where `id` = 1; | ||
update `coop_opens` set `day_of_week` = 'WEEKDAYS' where `id` = 1; | ||
update `coop_opens` set `day_of_week` = 'WEEKDAYS' where `id` = 2; | ||
update `coop_opens` set `day_of_week` = 'WEEKDAYS' where `id` = 3; | ||
update `coop_opens` set `day_of_week` = 'WEEKEND' where `id` = 4; | ||
update `coop_opens` set `day_of_week` = 'WEEKEND' where `id` = 5; | ||
update `coop_opens` set `day_of_week` = 'WEEKEND' where `id` = 6; | ||
|
||
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`) | ||
VALUES | ||
(2, '점심', 'WEEKDAYS', '11:40', '13:30'), | ||
(2, '점심', 'WEEKEND', '미운영', '미운영'), | ||
(3, 'NULL', 'WEEKDAYS', '08:30', '21:00'), | ||
(3, 'NULL', 'SATURDAY', '11:00', '18:00'), | ||
(4, 'NULL', 'WEEKDAYS', '09:00', '18:00'), | ||
(4, 'NULL', 'WEEKEND', '휴점', '휴점'), | ||
(5, 'NULL', 'WEEKDAYS', '11:30', '18:00'), | ||
(5, 'NULL', 'WEEKEND', '휴점', '휴점'), | ||
(6, 'NULL', 'WEEKDAYS', '08:30', '18:00'), | ||
(6, 'NULL', 'WEEKEND', '휴점', '휴점'), | ||
(7, 'NULL', 'WEEKDAYS', '24시간', '24시간'), | ||
(7, 'NULL', 'WEEKEND', '24시간', '24시간'), | ||
(8, 'NULL', 'WEEKDAYS', '09:30', '17:00'), | ||
(8, 'NULL', 'WEEKEND', '휴점', '휴점'), | ||
(9, 'NULL', 'WEEKDAYS', '24시간', '24시간'), | ||
(9, 'NULL', 'WEEKEND', '24시간', '24시간'); | ||
VALUES ('복지관식당', '041-560-1778', '복지관 2층', '능수관', 1); | ||
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`) | ||
VALUES (last_insert_id(), '점심', 'WEEKDAYS', '11:40', '13:30'), | ||
(last_insert_id(), '점심', 'WEEKEND', '미운영', '미운영'); | ||
|
||
INSERT INTO `coop_shop` (`name`, `phone`, `location`, `remarks`, `semester_id`) | ||
VALUES ('대즐', '041-560-1779', '복지관 1층', '배달 서비스, 공·일요일 미운영', 1); | ||
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`) | ||
VALUES (last_insert_id(), NULL, 'WEEKDAYS', '08:30', '21:00'), | ||
(last_insert_id(), NULL, 'SATURDAY', '11:00', '18:00'); | ||
|
||
INSERT INTO `coop_shop` (`name`, `phone`, `location`, `remarks`, `semester_id`) | ||
VALUES ('서점', '041-560-1756', '복지관 1층', '점심시간 12:00 - 13:00', 1); | ||
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`) | ||
VALUES (last_insert_id(), NULL, 'WEEKDAYS', '09:00', '18:00'), | ||
(last_insert_id(), NULL, 'WEEKEND', '휴점', '휴점'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cinsert 구문이 전부 동일한 형태에 value만 다른 것 같은데, 기존처럼 단일 insert문으로 묶어버리는 건 어떻게 생각하시나요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사용자 정의 변수를 사용하는 방향을 생각했습니다. 예시 SET @FIRST_ID = LAST_INSERT_ID();
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`)
VALUES
(@FIRST_ID, '점심', 'WEEKDAYS', '11:40', '13:30'),
(@FIRST_ID, '점심', 'WEEKEND', '미운영', '미운영'),
(@FIRST_ID + 1, 'NULL', 'WEEKDAYS', '08:30', '21:00'),
(@FIRST_ID + 1, 'NULL', 'SATURDAY', '11:00', '18:00'), |
||
|
||
INSERT INTO `coop_shop` (`name`, `phone`, `location`, `remarks`, `semester_id`) | ||
VALUES ('세탁소', '041-552-1489', '학생회관 2층', NULL, 1); | ||
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`) | ||
VALUES (last_insert_id(), NULL, 'WEEKDAYS', '11:30', '18:00'), | ||
(last_insert_id(), NULL, 'WEEKEND', '휴점', '휴점'); | ||
|
||
INSERT INTO `coop_shop` (`name`, `phone`, `location`, `remarks`, `semester_id`) | ||
VALUES ('복사실', '041-560-1093', '학생회관 2층', '점심시간 11:30 - 12:30', 1); | ||
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`) | ||
VALUES (last_insert_id(), NULL, 'WEEKDAYS', '08:30', '18:00'), | ||
(last_insert_id(), NULL, 'WEEKEND', '휴점', '휴점'); | ||
|
||
INSERT INTO `coop_shop` (`name`, `phone`, `location`, `remarks`, `semester_id`) | ||
VALUES ('복지관 참빛관 편의점', '041-560-1093', '복지관 1층, 참빛관 1층', '복지관 임시운영 별도공지', 1); | ||
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`) | ||
VALUES (last_insert_id(), NULL, 'WEEKDAYS', '24시간', '24시간'), | ||
(last_insert_id(), NULL, 'WEEKEND', '24시간', '24시간'); | ||
|
||
INSERT INTO `coop_shop` (`name`, `phone`, `location`, `remarks`, `semester_id`) | ||
VALUES ('미용실', '041-560-1769', '학생회관 1층', '예약제운영', 1); | ||
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`) | ||
VALUES (last_insert_id(), NULL, 'WEEKDAYS', '09:30', '17:00'), | ||
(last_insert_id(), NULL, 'WEEKEND', '휴점', '휴점'); | ||
|
||
INSERT INTO `coop_shop` (`name`, `phone`, `location`, `remarks`, `semester_id`) | ||
VALUES ('오락실', '041-560-1472', '학생회관 1층', NULL, 1); | ||
INSERT INTO coop_opens (`coop_shop_id`, `type`, `day_of_week`, `open_time`, `close_time`) | ||
VALUES (last_insert_id(), NULL, 'WEEKDAYS', '24시간', '24시간'), | ||
(last_insert_id(), NULL, 'WEEKEND', '24시간', '24시간'); | ||
|
||
UPDATE coop_shop | ||
SET semester_id = 1 | ||
WHERE name = '학생식당'; | ||
|
||
UPDATE coop_opens | ||
SET day_of_week = 'WEEKDAYS' | ||
WHERE coop_shop_id = 1 | ||
AND day_of_week = '평일'; | ||
|
||
UPDATE coop_opens | ||
SET day_of_week = 'WEEKEND' | ||
WHERE coop_shop_id = 1 | ||
AND day_of_week = '주말'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
참조 id를 알 수 없는 경우 어떻게 넣어줄 수 있나 고민했었는데
last_insert_id() 이런 함수가 있었네요