# CRM Migration Audit

Generated: 2026-07-30T21:45:42.076Z

Database: `C:\Users\goura\Desktop\Office365\msncodeportal-v2\server\db\office365.sqlite`

Database size: 4096 bytes

## Table Counts

| Table | Rows |
| --- | --- |
| admin_clocks | 0 |
| admin_tasks | 0 |
| admin_users | 1 |
| audit_logs | 0 |
| customers | 0 |
| email_logs | 0 |
| external_lead_imports | 0 |
| finance_agent_rates | 5 |
| finance_agents | 4 |
| finance_payment_modes | 3 |
| finance_payouts | 0 |
| finance_reserve_batch_items | 0 |
| finance_reserve_batches | 0 |
| finance_sale_allocations | 0 |
| finance_sales | 0 |
| integration_sources | 0 |
| invoice_settings | 0 |
| invoices | 0 |
| leads | 0 |
| notification_recipients | 0 |
| order_status_history | 0 |
| orders | 0 |
| password_reset_otps | 0 |
| payment_gateways | 0 |
| plans | 5 |
| reminders | 0 |
| sessions | 0 |
| site_content | 1 |
| smtp_profiles | 0 |

## Lead Status

| Status | Rows |
| --- | --- |
| - | - |

## Lead Agent Counts

| Agent | Rows |
| --- | --- |
| - | - |

## Invoice Payment Status

| Status | Rows | Total minor units |
| --- | --- | --- |
| - | - |

## Invoice Totals By Currency

| Currency | Rows | Amount minor |
| --- | --- | --- |
| - | - |

## Sales Totals By Currency

| Currency | Rows | Amount minor |
| --- | --- | --- |
| - | - |

## Reserve Totals

| Currency | Rows | Reserve minor | Released minor | Reserve payable INR paise |
| --- | --- | --- | --- | --- |
| - | - |

## Integrity Checks

| Check | Result |
| --- | --- |
| Duplicate customer emails | 0 |
| 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. |
