Files
codex-proxy-rs/backend/migrations/0004_remove_client_charge_reconciliation.sql
ZyyandCodex 4a413f5bb7 fix(budgets): remove manual charge reconciliation
Settle only observed USD costs and treat missing costs as zero without
blocking client keys. Preserve known retry costs and idempotent settlement.
Remove reconciliation controls, endpoints, pending records, and obsolete
schema fields; migrate legacy unknown charges to zero without changing
recorded usage.

Display daily and weekly amounts with two decimal places while retaining
full precision for accounting and tooltips. Distinguish missing WebSocket
closing handshakes from TCP resets in connection diagnostics.

Validation: workspace tests with PostgreSQL/Redis, targeted regressions,
strict Clippy, rustfmt, frontend lint/build, and migration checks passed.

Co-authored-by: Codex <noreply@openai.com>
2026-09-11 05:13:06 +08:00

18 lines
757 B
SQL

-- 移除人工核账:历史未取得费用的请求按零结算,已记录金额保持不变。
-- 迁移在监听请求前执行;遗留未完成记录不再阻断 Key。
update client_key_charge_events
set state = 'settled',
amount_usd = coalesce(amount_usd, 0),
completed_at = coalesce(completed_at, least(deadline_at, now()));
-- 费用表只保存已完成的幂等结算,不再维护预扣费和待核账状态。
drop index client_key_charge_events_unresolved;
alter table client_key_charge_events
drop column state,
drop column started_at,
drop column deadline_at,
drop column reconciled_at,
drop column reconciliation_reason,
alter column amount_usd set not null,
alter column completed_at set not null;