SET @base_staff_party_member_sql = IF(
    EXISTS(
        SELECT 1
        FROM information_schema.columns
        WHERE table_schema = DATABASE()
          AND table_name = 'ccdi_base_staff'
          AND column_name = 'is_party_member'
    ),
    'SELECT 1',
    'ALTER TABLE `ccdi_base_staff` ADD COLUMN `is_party_member` TINYINT(1) NOT NULL DEFAULT 0 COMMENT ''是否党员：0-否 1-是'' AFTER `hire_date`'
);

PREPARE base_staff_party_member_stmt FROM @base_staff_party_member_sql;
EXECUTE base_staff_party_member_stmt;
DEALLOCATE PREPARE base_staff_party_member_stmt;

INSERT INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, remark)
SELECT '是否标记', 'ccdi_yes_no_flag', '0', 'admin', NOW(), '是否标记列表'
WHERE NOT EXISTS (
    SELECT 1 FROM sys_dict_type WHERE dict_type = 'ccdi_yes_no_flag'
);

INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark)
SELECT 1, '是', '1', 'ccdi_yes_no_flag', '', 'primary', 'N', '0', 'admin', NOW(), '是'
WHERE NOT EXISTS (
    SELECT 1 FROM sys_dict_data WHERE dict_type = 'ccdi_yes_no_flag' AND dict_value = '1'
);

INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark)
SELECT 2, '否', '0', 'ccdi_yes_no_flag', '', 'danger', 'Y', '0', 'admin', NOW(), '否'
WHERE NOT EXISTS (
    SELECT 1 FROM sys_dict_data WHERE dict_type = 'ccdi_yes_no_flag' AND dict_value = '0'
);
