-- 专家证件与银行卡图片字段

SET @c := (SELECT COUNT(1) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'expert' AND COLUMN_NAME = 'id_card_front_oss_key');
SET @sql := IF(@c = 0, 'ALTER TABLE expert ADD COLUMN id_card_front_oss_key VARCHAR(512) NULL AFTER id_card_valid_until', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(1) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'expert' AND COLUMN_NAME = 'id_card_back_oss_key');
SET @sql := IF(@c = 0, 'ALTER TABLE expert ADD COLUMN id_card_back_oss_key VARCHAR(512) NULL AFTER id_card_front_oss_key', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(1) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'expert_bank_card' AND COLUMN_NAME = 'bank_card_front_oss_key');
SET @sql := IF(@c = 0, 'ALTER TABLE expert_bank_card ADD COLUMN bank_card_front_oss_key VARCHAR(512) NULL AFTER bank_card_no', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(1) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'expert_bank_card' AND COLUMN_NAME = 'bank_card_back_oss_key');
SET @sql := IF(@c = 0, 'ALTER TABLE expert_bank_card ADD COLUMN bank_card_back_oss_key VARCHAR(512) NULL AFTER bank_card_front_oss_key', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

ALTER TABLE expert
    MODIFY COLUMN id_card_front_oss_key VARCHAR(512) NULL COMMENT '身份证正面图片OSSKey',
    MODIFY COLUMN id_card_back_oss_key VARCHAR(512) NULL COMMENT '身份证反面图片OSSKey';

ALTER TABLE expert_bank_card
    MODIFY COLUMN bank_card_front_oss_key VARCHAR(512) NULL COMMENT '银行卡正面图片OSSKey',
    MODIFY COLUMN bank_card_back_oss_key VARCHAR(512) NULL COMMENT '银行卡反面图片OSSKey';
