-- ================================================================
-- 센터구분(CENTER_DIV_CD) 컬럼 추가 및 쁘띠센터 행 생성 마이그레이션
-- ================================================================

-- 1. 센터구분 컬럼 추가
ALTER TABLE MU_HOSPITAL ADD COLUMN CENTER_DIV_CD VARCHAR(10) DEFAULT 'DIET' COMMENT '센터구분(DIET/PETIT)' AFTER HOSPITAL_NAME;

-- 2. 기존 행을 다이어트센터로 설정
UPDATE MU_HOSPITAL SET CENTER_DIV_CD = 'DIET' WHERE USE_YN = 'Y';

-- 3. 쁘띠센터 행 생성 (기존 다이어트 운영시간을 복사, 운영시간은 별도 설정 필요)
INSERT INTO MU_HOSPITAL (
    MU_HOSPITAL_ID, HOSPITAL_NAME, CENTER_DIV_CD,
    MON_OPEN_YN, MON_OPEN_START_TIME, MON_OPEN_END_TIME, MON_BREAK_START_TIME, MON_BREAK_END_TIME,
    TUE_OPEN_YN, TUE_OPEN_START_TIME, TUE_OPEN_END_TIME, TUE_BREAK_START_TIME, TUE_BREAK_END_TIME,
    WED_OPEN_YN, WED_OPEN_START_TIME, WED_OPEN_END_TIME, WED_BREAK_START_TIME, WED_BREAK_END_TIME,
    THU_OPEN_YN, THU_OPEN_START_TIME, THU_OPEN_END_TIME, THU_BREAK_START_TIME, THU_BREAK_END_TIME,
    FRI_OPEN_YN, FRI_OPEN_START_TIME, FRI_OPEN_END_TIME, FRI_BREAK_START_TIME, FRI_BREAK_END_TIME,
    SAT_OPEN_YN, SAT_OPEN_START_TIME, SAT_OPEN_END_TIME, SAT_BREAK_START_TIME, SAT_BREAK_END_TIME,
    SUN_OPEN_YN, SUN_OPEN_START_TIME, SUN_OPEN_END_TIME, SUN_BREAK_START_TIME, SUN_BREAK_END_TIME,
    PUBLIC_HOLIDAY_USE_YN, MU_MEMBER_ID,
    WRITE_DATE, WRITE_TIME, CUD_FLAG, USE_YN, REG_ID, REG_DATE, MOD_ID, MOD_DATE
)
SELECT 
    CONCAT(LEFT(MU_HOSPITAL_ID, 24), '2'),  -- 새 ID 생성
    HOSPITAL_NAME, 'PETIT',
    MON_OPEN_YN, MON_OPEN_START_TIME, MON_OPEN_END_TIME, MON_BREAK_START_TIME, MON_BREAK_END_TIME,
    TUE_OPEN_YN, TUE_OPEN_START_TIME, TUE_OPEN_END_TIME, TUE_BREAK_START_TIME, TUE_BREAK_END_TIME,
    WED_OPEN_YN, WED_OPEN_START_TIME, WED_OPEN_END_TIME, WED_BREAK_START_TIME, WED_BREAK_END_TIME,
    THU_OPEN_YN, THU_OPEN_START_TIME, THU_OPEN_END_TIME, THU_BREAK_START_TIME, THU_BREAK_END_TIME,
    FRI_OPEN_YN, FRI_OPEN_START_TIME, FRI_OPEN_END_TIME, FRI_BREAK_START_TIME, FRI_BREAK_END_TIME,
    SAT_OPEN_YN, SAT_OPEN_START_TIME, SAT_OPEN_END_TIME, SAT_BREAK_START_TIME, SAT_BREAK_END_TIME,
    SUN_OPEN_YN, SUN_OPEN_START_TIME, SUN_OPEN_END_TIME, SUN_BREAK_START_TIME, SUN_BREAK_END_TIME,
    PUBLIC_HOLIDAY_USE_YN, MU_MEMBER_ID,
    CURDATE(), CURTIME(), 'C', 'Y', 'SYSTEM', NOW(), 'SYSTEM', NOW()
FROM MU_HOSPITAL
WHERE USE_YN = 'Y' AND CENTER_DIV_CD = 'DIET'
LIMIT 1;
