Files
weibo_signin/migrate_fix_signin_logs_fk.sql
2026-04-01 15:13:37 +08:00

11 lines
414 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 修复 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;