-- 全面检查所有可能有 JOIN 冲突的表
USE aidopdev;

-- 检查所有 Master 表的 Domain 和 Site 字段
SELECT 
    TABLE_NAME, 
    COLUMN_NAME, 
    COLUMN_TYPE, 
    COLLATION_NAME,
    CASE 
        WHEN COLLATION_NAME = 'utf8mb4_general_ci' THEN '✓ OK'
        WHEN COLLATION_NAME = 'utf8mb4_0900_ai_ci' THEN '✗ 需修复'
        ELSE '其他'
    END AS 状态
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_SCHEMA = 'aidopdev' 
  AND TABLE_NAME LIKE '%Master%'
  AND COLUMN_NAME IN ('Domain', 'Site', 'Line', 'Item', 'Department', 'Cust', 'Customer')
  AND COLLATION_NAME IS NOT NULL
ORDER BY 
    CASE WHEN COLLATION_NAME = 'utf8mb4_0900_ai_ci' THEN 0 ELSE 1 END,
    TABLE_NAME, 
    COLUMN_NAME;
