Databases
AuraScore 89/100

Lease Ledger Migration Verification Script

Generate an automated Python validation script to reconcile rent roll records and financial ledger integrity across database migrations.

Use when migrating property management databases, tenant ledgers, or commercial leases between legacy and cloud systems. It creates test fixtures, discrepancy audit queries, and verification assertions.

Template

Role: Lead Database Data Engineer specializing in commercial real estate financial data migrations.

Context

  • Legacy source database connection: {{source_erp_database}}
  • Destination tenant table: {{target_tenant_table}}
  • Destination accounting ledger table: {{ledger_entry_table}}
  • Maximum allowed financial rounding delta: {{discrepancy_tolerance_amount}}
  • Verification cursor batch size: {{validation_batch_size}}
  • Output log format: {{reporting_output_format}}

Task

Write a robust Python validation script that extracts financial balances, recurring lease escalations, and security deposits from {{source_erp_database}}, comparing them against {{target_tenant_table}} and {{ledger_entry_table}} to assert 100% data fidelity post-migration.

Method

  1. Initialize database connection pools with read-only credentials for source and target databases.
  2. Formulate parameterized aggregation queries extracting total balance, prepaid rent, and active lease count grouped by property ID.
  3. Execute chunked validation reads using {{validation_batch_size}} to manage memory consumption.
  4. Compare ledger sums per lease, flagging discrepancies that exceed {{discrepancy_tolerance_amount}}.
  5. Validate foreign key consistency between {{target_tenant_table}} and {{ledger_entry_table}} records.
  6. Generate an automated summary matrix tracking matched records, unmatched IDs, and variance magnitudes.
  7. Format discrepancy logs and summary data according to {{reporting_output_format}}.

Constraints

  • MUST run purely read-only queries with zero mutations on source or destination tables.
  • MUST NOT load entire financial ledgers into memory at once; streaming cursors must be used.
  • Currency computations MUST use Python Decimal types rather than standard IEEE floating-point.
  • Script execution must exit with status code 1 if any discrepancy surpasses {{discrepancy_tolerance_amount}}.

Output format

A standalone Python 3 script containing:

  1. Imports, CLI Arguments, and Connection Setup (max 30 lines)
  2. SQL Reconciliation Queries and Aggregation Logic (max 50 lines)
  3. Batch Execution Engine and Assertions (max 60 lines)
  4. Report Exporter in {{reporting_output_format}} (max 40 lines)

Self-review

  • Ensure floating-point arithmetic is completely replaced with Python's Decimal class.
  • Confirm that database connection handlers properly close cursors and pools on SIGINT or unhandled exceptions.
  • Check that discrepancy reporting surfaces exact property IDs, tenant IDs, and ledger line numbers.
AuraScore breakdown
89/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification14/14 · Strong

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-databases
real-estate-construction
python
etl-verification
accounting-ledger