From 22fe23914f943960b2f9cac8c91fa4460805b020 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 12 Jan 2026 09:59:11 -0800 Subject: [PATCH] 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 --- .../migration.sql | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/backend/services/contribution-service/prisma/migrations/20260113110000_fix_team_bonus_data/migration.sql b/backend/services/contribution-service/prisma/migrations/20260113110000_fix_team_bonus_data/migration.sql index bc4e6460..3c0f3e74 100644 --- a/backend/services/contribution-service/prisma/migrations/20260113110000_fix_team_bonus_data/migration.sql +++ b/backend/services/contribution-service/prisma/migrations/20260113110000_fix_team_bonus_data/migration.sql @@ -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 -);