SET @apple_user_identifier_column_exists = ( SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'tcm_app_user' AND COLUMN_NAME = 'apple_user_identifier' ); SET @apple_user_identifier_alter_sql = IF( @apple_user_identifier_column_exists = 0, 'ALTER TABLE `tcm_app_user` ADD COLUMN `apple_user_identifier` VARCHAR(128) DEFAULT NULL COMMENT ''苹果用户标识'' AFTER `wechat_bound_at`', 'SELECT 1' ); PREPARE apple_user_identifier_stmt FROM @apple_user_identifier_alter_sql; EXECUTE apple_user_identifier_stmt; DEALLOCATE PREPARE apple_user_identifier_stmt; SET @apple_identity_subject_column_exists = ( SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'tcm_app_user' AND COLUMN_NAME = 'apple_identity_subject' ); SET @apple_identity_subject_alter_sql = IF( @apple_identity_subject_column_exists = 0, 'ALTER TABLE `tcm_app_user` ADD COLUMN `apple_identity_subject` VARCHAR(128) DEFAULT NULL COMMENT ''苹果身份主题标识'' AFTER `apple_user_identifier`', 'SELECT 1' ); PREPARE apple_identity_subject_stmt FROM @apple_identity_subject_alter_sql; EXECUTE apple_identity_subject_stmt; DEALLOCATE PREPARE apple_identity_subject_stmt; SET @apple_bound_at_column_exists = ( SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'tcm_app_user' AND COLUMN_NAME = 'apple_bound_at' ); SET @apple_bound_at_alter_sql = IF( @apple_bound_at_column_exists = 0, 'ALTER TABLE `tcm_app_user` ADD COLUMN `apple_bound_at` DATETIME DEFAULT NULL COMMENT ''苹果绑定时间'' AFTER `apple_identity_subject`', 'SELECT 1' ); PREPARE apple_bound_at_stmt FROM @apple_bound_at_alter_sql; EXECUTE apple_bound_at_stmt; DEALLOCATE PREPARE apple_bound_at_stmt;