Skip to content

feat(maintenance): Prisma Decimal migration and schema hardening - #199

Merged
rajputomsingh merged 6 commits into
masterfrom
maintenance
Aug 12, 2026
Merged

feat(maintenance): Prisma Decimal migration and schema hardening#199
rajputomsingh merged 6 commits into
masterfrom
maintenance

Conversation

@rajputomsingh

@rajputomsingh rajputomsingh commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Overview

Hardened Fieldly's persistence and financial domain model by completing the Prisma Decimal migration and introducing stronger lease, payment, security, and concurrency guarantees.

This change establishes the data-layer foundation required for reliable lease execution and payment processing while tightening destructive operations and sensitive session handling.

Financial Data Integrity

Decimal Migration

  • Migrated monetary fields from Float to Decimal
  • Added shared Decimal utilities for consistent money handling
  • Fixed Decimal serialization and TypeScript boundary issues across 30+ files
  • Updated notification and application services to safely handle monetary values

This removes floating-point representation from financial calculations and establishes consistent monetary precision across the application.

Lease Lifecycle

Added dedicated persistence models for the lease execution lifecycle:

  • LeaseAgreement — contract representation
  • LeaseSignature — contract signing state
  • LeasePaymentSchedule — payment obligations
  • LeaseEvent — immutable lease audit timeline
  • LandAvailabilityStatus — land availability state

These models establish explicit state and audit boundaries instead of relying on loosely coupled application records.

Payment Integrity

  • Added PaymentWebhookEvent for idempotent Razorpay webhook processing
  • Added PaymentProvider and PaymentType enums
  • Added payment lifecycle persistence
  • Prevented duplicate webhook processing through persisted event tracking

Concurrency & Leasing Protection

  • Added optimistic concurrency using version fields on critical entities
  • Added land availability state to prevent double-leasing
  • Added composite indexes for critical query paths
  • Strengthened persistence constraints around lease and payment operations

Security Hardening

  • Replaced plaintext AdminSession tokens with tokenHash
  • Added token-hash backfill migration
  • Updated session management to operate against hashed tokens
  • Replaced destructive financial-record cascades with Restrict / SetNull semantics

This reduces the risk of accidental financial-record deletion and limits exposure of sensitive session credentials.

Schema & Migration Safety

  • Added production migration:
    20260811181655_lease_execution_foundation
  • Updated Prisma schema and generated types
  • Added compatibility fixes for existing database indexes
  • Added migration-safe handling for existing LandListing indexes

Impact

  • Established precise monetary representation across the financial domain
  • Added explicit lease-contract and payment lifecycle persistence
  • Strengthened protection against double-leasing and concurrent updates
  • Added idempotent payment webhook processing
  • Improved auditability through immutable lease events
  • Hardened admin session storage
  • Reduced the risk of destructive database cascades affecting financial records
  • Improved query performance through composite indexing

Validation

  • ✅ Prisma schema validation
  • ✅ Database migration status verified
  • ✅ Decimal boundary issues resolved across 30+ files
  • ✅ Production build
  • ✅ Vercel preview deployment
  • ✅ Migration/index compatibility fixes verified
  • ✅ Admin session token hash migration verified

Breaking Change

Monetary fields previously represented as Float now use Decimal.

Existing integrations and application boundaries handling monetary values were updated accordingly.

Outcome

Fieldly's data layer now provides stronger guarantees around financial precision, lease lifecycle integrity, payment idempotency, concurrency, and sensitive session data.

This establishes the persistence foundation required for reliable lease execution and future payment workflows.

- Migrated all monetary fields from Float to Decimal for financial precision
- Added LeaseAgreement and LeaseSignature models for contract lifecycle
- Added LeasePaymentSchedule for payment obligations tracking
- Added LeaseEvent for immutable lease audit timeline
- Added LandAvailabilityStatus to prevent double-leasing
- Added PaymentWebhookEvent for idempotent Razorpay webhook processing
- Added PaymentProvider and PaymentType enums
- Changed AdminSession token to tokenHash for security
- Replaced onDelete: Cascade with Restrict/SetNull for financial records
- Added optimistic concurrency (version fields) to critical entities
- Added composite indexes for query performance
- Added Decimal utility functions for consistent money handling
- Fixed all TypeScript Decimal boundary errors across 30+ files
- Updated session-manager for token hashing
- Fixed notification service for Decimal formatting

Breaking: Float monetary fields now use Decimal type
Migration: 20260811181655_lease_execution_foundation
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fieldly Ready Ready Preview Aug 12, 2026 9:00am

@rajputomsingh rajputomsingh self-assigned this Aug 12, 2026
@rajputomsingh rajputomsingh added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request release:vanguard Trust infrastructure, payments, verification, and leasing workflows. labels Aug 12, 2026
@rajputomsingh rajputomsingh added this to the Catalyst (v0.6.0-beta) milestone Aug 12, 2026
@rajputomsingh
rajputomsingh merged commit 654e928 into master Aug 12, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request release:vanguard Trust infrastructure, payments, verification, and leasing workflows.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant