-- Manual apply: binding target account columns (tenant DB) SET @col_exists := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'company_tag_template_binding' AND COLUMN_NAME = 'target_qw_user_ids'); SET @ddl := IF(@col_exists = 0, 'ALTER TABLE company_tag_template_binding ADD COLUMN target_qw_user_ids VARCHAR(2000) NULL COMMENT ''限定企微员工ID'' AFTER target_channels', 'SELECT 1'); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; SET @col_exists := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'company_tag_template_binding' AND COLUMN_NAME = 'target_wx_account_ids'); SET @ddl := IF(@col_exists = 0, 'ALTER TABLE company_tag_template_binding ADD COLUMN target_wx_account_ids VARCHAR(2000) NULL COMMENT ''限定个微账号ID'' AFTER target_qw_user_ids', 'SELECT 1'); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt;