-- =============================================
-- 数据库迁移脚本：为 member_driver 表添加 id_card 字段
-- 用途：存储司机身份证前后面照片地址
-- 创建时间：2025-10-20
-- =============================================

-- 检查字段是否已存在，如果不存在则添加
SET @sql = (
    SELECT IF(
        (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS 
         WHERE TABLE_SCHEMA = DATABASE() 
           AND TABLE_NAME = 'member_driver' 
           AND COLUMN_NAME = 'id_card') = 0,
        'ALTER TABLE member_driver ADD COLUMN id_card TEXT COMMENT ''身份证前后面照片地址（多个URL用逗号分隔）'' AFTER car_img;',
        'SELECT ''字段 id_card 已存在，无需添加'' AS message;'
    )
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

-- 显示表结构确认字段已添加
DESCRIBE member_driver;

-- 显示添加结果
SELECT 'id_card 字段添加完成' AS result;
