Files
cattleTransportation/tradeCattle/database_migration_add_id_card_field.sql
2025-10-21 09:01:11 +08:00

28 lines
959 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- =============================================
-- 数据库迁移脚本:为 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;