You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migrate Float monetary fields to Decimal in Prisma schema #237
Problem Statement. Money is stored as Float in Campaign.budget, Claim.amount, AidPackage.totalAmount/claimedAmount/remainingAmount, and BalanceLedger.amount. Doubles
cannot represent one USDC cent exactly and SQLite further mangles them.
Why it matters. Floats in money-handling systems are a class of bug. The schema is
the cross-language boundary; a Swift or Go client that reads these values can pick up 0.1 + 0.2 == 0.30000000000000004 and proceed to disburse incorrectly.
Technical Context.prisma/schema.prisma. Decimal is supported by Prisma + Postgres
natively; for SQLite the round-trip goes via string.
Expected Outcome. All monetary fields use Decimal with String representation for
the JS client. Existing data is migrated in a single script using BigInt arithmetic.
Acceptance Criteria.
New schema field types: Decimal @db.Decimal(38, 18).
A migration script prisma/migrations/<ts>_floats_to_decimal/migration.sql covers the
four models.
A unit-test in app/backend/test/money-roundtrip.spec.ts proves Decimal("1000.5") round-trips losslessly through Python, JS, and Postgres client.
API responses explicitly serialize decimals as strings (use a custom DecimalSerializerInterceptor).
Implementation Notes. Avoid parseFloat anywhere in the consumer code; use Decimal js.
Files or modules likely to be affected.prisma/schema.prisma, prisma/migrations/*, src/common/decimal.ts (new), src/main.ts.
Activity
DeRossa1 commentedon Jul 21, 2026
I can resolve this issue, assign me.
grantfox-oss commentedon Jul 21, 2026
🦊 GrantFox — @DeRossa1 has been assigned to this issue as part of the Official Campaign | FWC26 campaign!
Next steps:
Closes #237)Good luck! Track your progress on GrantFox.
refactor(backend): migrate Float monetary fields to Decimal (#237) (#410
grantfox-oss commentedon Jul 22, 2026
🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign | FWC26 campaign!
@DeRossa1's PR #410 was approved and merged by @kilodesodiq-arch.
🏆 @DeRossa1: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (83 total points). Track your full progress on GrantFox.
👏 Great work, @DeRossa1! Keep contributing to ChainForgee.
refactor(backend): migrate Float monetary fields to Decimal (ChainFor…