· 4 min read
How to prove a data migration worked: counts, checksums and diffs
Prove a data migration worked: row counts, aggregates, row hashes and key-based diffs — and how to normalise data so you compare values, not formatting.
15 tools
Convert schemas and data between MySQL, PostgreSQL, SQLite and SQL Server, generate ORM models from an existing database, and check that what arrived matches what left.
Convert the schema first and load it into an empty staging database. Schema problems — a type with no equivalent, an index that is too long, a default the target rejects — are cheap to fix before any data is involved.
Then move the data. For small and medium databases the converted INSERT statements are enough. For very large ones, use the target's bulk loader (COPY, LOAD DATA, bcp) with CSV exports, and keep the converted schema.
Finally, prove it. Compare row counts per table, then export a few critical tables from both sides and diff them by primary key with the CSV compare tool. Cut over only when the diff is empty or every difference is explained.
Stored procedures, triggers and functions are programs written in each database's own language. They need to be rewritten and tested by a person. The converters here pass them through untouched and flag them, rather than producing something that looks right and isn't.
Application queries matter as much as the schema: date arithmetic, string concatenation, case sensitivity in comparisons and GROUP BY strictness all differ between engines. Run your test suite against the new database before the switch.
· 4 min read
Prove a data migration worked: row counts, aggregates, row hashes and key-based diffs — and how to normalise data so you compare values, not formatting.
· 6 min read
Migrating from MySQL to PostgreSQL: type mapping, AUTO_INCREMENT and sequences, zero dates, case sensitivity, query rewrites and how to verify the result.