-- 考勤分组增加可拆分半天休假天数字段
-- 执行日期：2026-03-26

SET @db_name = DATABASE();
SET @ddl = (
    SELECT IF(
        EXISTS(
            SELECT 1
            FROM information_schema.COLUMNS
            WHERE TABLE_SCHEMA = @db_name
              AND TABLE_NAME = 'lq_attendance_group'
              AND COLUMN_NAME = 'F_HalfDaySplitRestDays'
        ),
        'SELECT 1',
        'ALTER TABLE `lq_attendance_group` ADD COLUMN `F_HalfDaySplitRestDays` int NOT NULL DEFAULT 0 COMMENT ''可拆分半天休假天数'' AFTER `F_MonthlyRestDays`'
    )
);

PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

UPDATE `lq_attendance_group`
SET `F_HalfDaySplitRestDays` = 0
WHERE `F_HalfDaySplitRestDays` IS NULL;

ALTER TABLE `lq_attendance_group`
MODIFY COLUMN `F_HalfDaySplitRestDays` int NOT NULL DEFAULT 0 COMMENT '可拆分半天休假天数' AFTER `F_MonthlyRestDays`;
