-- =============================================
-- 测试脚本：验证 id_card 字段
-- 用途：验证 member_driver 表的 id_card 字段是否正确添加
-- =============================================

-- 1. 检查表是否存在
SELECT 
    CASE 
        WHEN COUNT(*) > 0 THEN 'member_driver 表存在'
        ELSE 'member_driver 表不存在'
    END AS table_status
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = DATABASE() 
  AND TABLE_NAME = 'member_driver';

-- 2. 检查 id_card 字段是否存在
SELECT 
    CASE 
        WHEN COUNT(*) > 0 THEN 'id_card 字段存在'
        ELSE 'id_card 字段不存在'
    END AS column_status
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_SCHEMA = DATABASE() 
  AND TABLE_NAME = 'member_driver' 
  AND COLUMN_NAME = 'id_card';

-- 3. 显示 id_card 字段的详细信息
SELECT 
    COLUMN_NAME as '字段名',
    DATA_TYPE as '数据类型',
    CHARACTER_MAXIMUM_LENGTH as '最大长度',
    IS_NULLABLE as '允许空值',
    COLUMN_DEFAULT as '默认值',
    COLUMN_COMMENT as '注释',
    ORDINAL_POSITION as '字段位置'
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_SCHEMA = DATABASE() 
  AND TABLE_NAME = 'member_driver' 
  AND COLUMN_NAME = 'id_card';

-- 4. 显示 member_driver 表的完整结构
DESCRIBE member_driver;

-- 5. 测试插入和查询（可选，仅用于测试）
-- INSERT INTO member_driver (member_id, username, car_number, id_card, create_time) 
-- VALUES (999, '测试司机', '测试车牌', 'https://example.com/id1.jpg,https://example.com/id2.jpg', NOW());

-- SELECT id, username, car_number, id_card FROM member_driver WHERE username = '测试司机';

-- DELETE FROM member_driver WHERE username = '测试司机';
