-- 修复 signin_logs 外键
-- 用法: mysql -u weibo -p123456 weibo_hotsign < migrate_fix_signin_logs_fk.sql

-- 1. 清理孤儿记录
DELETE FROM signin_logs WHERE account_id NOT IN (SELECT id FROM accounts);

-- 2. 重建外键（带 CASCADE），忽略已存在的情况
ALTER TABLE signin_logs
    ADD CONSTRAINT fk_signin_logs_account
    FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE;
