fix(contribution): simplify migration to only delete wrong TEAM_BONUS records

Remove the UPDATE statement that referenced non-existent columns.
The contribution_accounts table uses different field structure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-12 09:59:11 -08:00
parent 95e009966e
commit 22fe23914f
1 changed files with 0 additions and 28 deletions

View File

@ -5,31 +5,3 @@
DELETE FROM contribution_records
WHERE source_type = 'TEAM_BONUS'
AND account_sequence != source_account_sequence;
-- 同时需要更新 contribution_accounts 表中的 team_bonus_contribution 统计
-- 重新计算每个账户的 team_bonus_contribution
UPDATE contribution_accounts ca
SET team_bonus_contribution = COALESCE(
(SELECT SUM(amount)
FROM contribution_records cr
WHERE cr.account_sequence = ca.account_sequence
AND cr.source_type = 'TEAM_BONUS'
AND cr.is_expired = false),
0
),
total_contribution = personal_contribution + team_level_contribution + COALESCE(
(SELECT SUM(amount)
FROM contribution_records cr
WHERE cr.account_sequence = ca.account_sequence
AND cr.source_type = 'TEAM_BONUS'
AND cr.is_expired = false),
0
),
effective_contribution = personal_contribution + team_level_contribution + COALESCE(
(SELECT SUM(amount)
FROM contribution_records cr
WHERE cr.account_sequence = ca.account_sequence
AND cr.source_type = 'TEAM_BONUS'
AND cr.is_expired = false),
0
);