Skip to content

Data migration testing: how to prove nothing was lost

B2Bnetwork team · · 6 min

Testing and quality

In brief

Proof that a data migration lost nothing has four layers: completeness (every source record is in the target or on the rejected list with a reason), matching totals (balances, stock levels, amounts), correct transformations (mapping rules checked field by field on a sample) and business continuity (people can keep working on the migrated data in the new system). Each layer has checks that run automatically after every trial migration, and the results go into a report signed off by the data owner.

What "nothing was lost" means

"The record count matches" is not enough. The number of customers can match while half of them have swapped addresses. That is why the proof is built in layers, and each layer catches a different kind of defect.

LayerQuestionExample checkWhat defect it catches
Completenessdoes every record have its counterpartcomparing keys in source and targetlost records, duplicates
Matching totalsdo values match in aggregatesum of balances at end of day, stock per warehousetruncated amounts, wrong signs, lost lines
Correct transformationsdo the mapping rules worka field-by-field sample against the mapping specificationwrong code list, swapped fields, character encoding
Business continuitycan people keep workingissuing a credit note for a migrated invoicemissing links, wrong statuses, unusable data

The first two layers can be fully automated. The third needs a mapping specification and a sample; the fourth needs people from the business.

Technical checks: counts, totals and key comparison

Technical checks are written as queries that run after every trial migration. Compare record counts by group rather than in total, because errors in one group can cancel out errors in another.

CheckSourceTargetResult
Active customers by type41,23041,230match
Open invoices8,9148,9113 missing, to investigate
Total open receivables12,480,312.5512,480,312.55match
Warehouse 01, number of items6,4026,402match
Warehouse 01, total quantity1,204,8771,204,830difference of 47, to investigate

The figures in the table are an example. When a difference appears, you need to find the specific records. If the source data can be loaded into the same database as the target (for example into a separate schema), the EXCEPT operator helps: it returns rows from the first query that are not in the second:

-- open invoices in the source that are missing from the target
SELECT invoice_number FROM source.invoices WHERE status = 'OPEN'
EXCEPT
SELECT invoice_number FROM target.invoices WHERE status = 'OPEN';

The same operator, applied to all columns after normalizing formats (dates, decimals, trailing spaces), points to records that were migrated but with a changed value. For large tables, compare row hashes calculated the same way on both sides, and compare full rows only where the hashes differ.

Mapping rules and rejected records

Every migration rejects something: a customer without a tax ID, an invoice with a non-existent counterparty, an item with a unit of measure the new system does not know. The trouble starts when the rejection is silent. That is why one equation applies, checked for every table:

records in the source = migrated + rejected with a reason + deliberately skipped by decision

The rejected list has an owner on the business side, who decides: fix it in the source and migrate again, migrate it manually or skip it. Deliberately skipped records (for example customers inactive for ten years) need a written decision, because six months later someone will ask where they went.

The mapping specification describes where every target field comes from and how it is transformed. Without it, a field-by-field test has nothing to compare against. A wrong code list (for example an old VAT rate mapped to a new one) is one of the most common defects, and it passes both count and total checks.

Field-level samples and business tests

Total checks will not detect that two customers had their phone numbers swapped. That is what a field-by-field sample is for. The sample is stratified rather than drawn at random from everything: a few records of each customer type, product and status, plus unusual records (the longest names, diacritics, zero and negative values, the oldest dates). A random sample from the whole set mostly hits typical records, which work anyway.

Business tests are performed by people from the departments, on the migrated data:

  1. Opening a customer record and comparing it with what the account manager knows.
  2. Issuing a credit note for an invoice from before the migration.
  3. Matching a payment to an invoice migrated as open.
  4. Dispatching goods from a batch migrated with an expiry date.
  5. Running the overdue receivables report and comparing it with the old system's report.

This layer catches linking errors: the invoice was migrated, the customer was migrated, but the invoice does not point to the customer.

Trial migrations and cutover day

The migration is run several times before go-live, and every trial ends with a report of checks across all layers. After the second or third trial, the results should stabilize and the rejected list should shrink. The final trial takes place under cutover conditions: full data, within the planned time window, with the same people and the same order of steps. You measure the migration time including checks, because that decides whether the window is long enough. More on preparing a new system's go-live in ERP implementation testing, and on the specifics of banks in Data migration testing in a bank.

Personal data in migration testing

Migration testing needs real data, because only real data has real defects. That means personal data in test environments. The GDPR requires, among other things, data minimization and restricted access (Article 5), and a data processing agreement with an external contractor (Article 28). In practice: access only for the people testing the migration, an environment with the same safeguards as production, and deletion of copies after the trials. Fields not needed for the test (such as ID document numbers) can be masked with the same function on both sides, which does not break the comparisons. More in Test data and the GDPR.

At B2Bnetwork we test migrations in projects for banks, insurers and companies with many systems. In our data and reporting service, the reconciliation checks against the source stay in place after the migration, so a discrepancy between the system and the report shows up immediately, not at year-end close.

Questions and answers

Is it enough to compare record counts before and after migration?

No. A matching record count does not detect swapped fields, truncated amounts or wrong code lists. It is the first and cheapest check, but you also need value totals by group, a key comparison, a field-by-field sample and business tests on the migrated data.

How many trial migrations are needed before go-live?

Usually at least three: a data sample to check the mapping, a full migration into the test environment and a dress rehearsal under cutover conditions. Large systems with many sources need more. The finish line is a stable check result and a rejected list accepted by the data owners.

How large should the field-by-field sample be?

There is no single number. Selection matters more than size: a few records from each category (customer type, status, product) plus unusual records. A few hundred well-chosen records tell you more than several thousand random ones. A full comparison of all rows is done automatically, with hashes.

Who signs off on the data migration?

The data owners on the business side: the CFO for balances and receivables, the warehouse manager for stock levels, the sales manager for customer records. The migration team presents the check report and the rejected list, but the decision that the data is ready for work belongs to the people who will work with it.

What it looks like in a project

Planning testing for your project? Talk to a test manager.

Let's talk

Read more: Testing and quality

All in Testing and quality →