# CRM Migration Audit

Generated: 2026-07-30T22:21:47.172Z

Database: `C:\Users\goura\Desktop\Office365\production-office365-20260731-032012.sqlite`

Database size: 1028096 bytes

## Table Counts

| Table | Rows |
| --- | --- |
| admin_clocks | 4 |
| admin_tasks | 8 |
| admin_users | 5 |
| audit_logs | 541 |
| customers | 211 |
| email_logs | 90 |
| external_lead_imports | 25 |
| finance_agent_rates | 7 |
| finance_agents | 6 |
| finance_payment_modes | 5 |
| finance_payouts | 152 |
| finance_reserve_batch_items | 52 |
| finance_reserve_batches | 7 |
| finance_sale_allocations | 10 |
| finance_sales | 212 |
| integration_sources | 0 |
| invoice_settings | 1 |
| invoices | 42 |
| leads | 222 |
| notification_recipients | 0 |
| order_status_history | 331 |
| orders | 222 |
| password_reset_otps | 0 |
| plans | 7 |
| reminders | 0 |
| sessions | 68 |
| site_content | 1 |
| smtp_profiles | 1 |

## Lead Status

| Status | Rows |
| --- | --- |
| converted | 185 |
| disputed | 20 |
| closed | 4 |
| refunded | 4 |
| cancelled | 3 |
| contacted | 3 |
| new | 2 |
| dispute_won | 1 |

## Lead Agent Counts

| Agent | Rows |
| --- | --- |
| Ashish Kumar | 75 |
| Priyank Jain | 75 |
| Deep Kumar | 57 |
| (unassigned) | 11 |
| Rahul Singh | 3 |
| Deepika | 1 |

## Invoice Payment Status

| Status | Rows | Total minor units |
| --- | --- | --- |
| unpaid | 25 | 499976 |
| paid | 17 | 419983 |

## Invoice Totals By Currency

| Currency | Rows | Amount minor |
| --- | --- | --- |
| USD | 42 | 919959 |

## Sales Totals By Currency

| Currency | Rows | Amount minor |
| --- | --- | --- |
| GBP | 22 | 1197500 |
| USD | 200 | 6804913 |

## Reserve Totals

| Currency | Rows | Reserve minor | Released minor | Reserve payable INR paise |
| --- | --- | --- | --- | --- |
| GBP | 22 | 0 | 1051100 | 0 |
| USD | 190 | 514500 | 5263948 | 3780000 |

## Integrity Checks

| Check | Result |
| --- | --- |
| Duplicate customer emails | 4 |
| Duplicate invoice numbers | 0 |
| Orphan leads without order | 0 |
| Orphan orders without customer | 0 |
| Orphan invoices without order | 0 |
| Orphan finance sales without order | 0 |
| Missing lead agents | 0 |
| Missing order agents | 0 |
| Null important fields | 0 |

## Migration Plan

| Entity | Source | Destination | Rule | Rollback |
| --- | --- | --- | --- | --- |
| Payment gateways | invoice_settings.payment_links | payment_gateways | Seed active default gateway from first configured legacy payment link when no gateway exists. Preserve legacy links. | Keep legacy payment_links untouched; archive inserted payment gateway if rollout is cancelled. |
| Invoice gateway snapshots | invoices.payment_links plus selected gateway on new sends | invoices.payment_gateway_id/payment_gateway_snapshot | New unpaid invoices store selected gateway snapshot. Existing invoice links remain unchanged. | Ignore new nullable columns; historical payment_links still render. |
| Paid invoice sales linkage | invoices, orders, finance_sales | orders/finance_sales relationship | Link only where order/invoice relationship is certain. Do not create duplicate finance_sales. | Remove only new linkage rows recorded in audit/mapping table. |
| Finance and reserve values | finance_sales, finance_payouts, finance_reserve_batches | retained tables | Preserve historical amounts, currencies, sale dates, payout dates, reserve dates, and settlement status. | Restore database backup if financial reconciliation fails. |
