-- Active: 1763990602551@@192.144.167.231@3306@autoaiworksys
-- ============================================
-- 为 pla_account 表中的所有账号创建默认的 account_config 配置
-- ============================================

-- 为所有启用的账号创建默认配置（如果配置不存在）
INSERT INTO account_config (account_id, platform_type, notes, created_time, last_update_time)
SELECT 
    id AS account_id,
    platform_type,
    '默认配置' AS notes,
    NOW() AS created_time,
    NOW() AS last_update_time
FROM pla_account
WHERE is_delete = 0
  AND id NOT IN (SELECT account_id FROM account_config)
ON DUPLICATE KEY UPDATE
    last_update_time = NOW();

-- 查看创建的结果
SELECT 
    ac.account_id,
    pa.name AS account_name,
    pa.sn_code,
    ac.platform_type,
    ac.platform_config,
    ac.auto_deliver_config,
    ac.auto_chat_config,
    ac.auto_active_config,
    ac.notes,
    ac.created_time,
    ac.last_update_time
FROM account_config ac
INNER JOIN pla_account pa ON ac.account_id = pa.id
ORDER BY ac.account_id;

