Skip to main content

Reproducible PostgreSQL migration validation lab

This synthetic PostgreSQL-to-PostgreSQL exercise shows why matching counts and totals are insufficient. It uses temporary source and target tables in one session, checks the expected discrepancies, repairs the target and checks again. It does not execute SmartDiff or validate a cloud connector pair.

Run on a disposable PostgreSQL database​

Use a non-production PostgreSQL database and a role allowed to create temporary tables. Download postgres-lab.sql, then run it through psql with your disposable connection already configured. The script creates only temporary tables, refuses to overwrite existing tables with those names, and rolls back on completion.

psql "$LAB_DATABASE_URL" -X -v ON_ERROR_STOP=1 -f postgres-lab.sql

LAB_DATABASE_URL must point to your disposable lab database. Keep credentials out of shared logs. -X avoids local psql startup customizations; ON_ERROR_STOP returns an error if a SQL assertion fails. No cloud credentials are required.

Expected discrepancies​

All amounts are synthetic USD orders, stored as numeric(12,2). Both sides contain three rows and total 75.00.

Order IDSource amountTarget amountExpected classification
10125.0025.00Unchanged
10240.0039.00Changed value
10310.00absentMissing from target
104absent11.00Unexpected in target

The union contains four keys: one unchanged, one changed, one missing and one unexpected. There are three discrepant keys, not three changed rows. The fixture uses IS DISTINCT FROM for null-safe value comparison and a full outer join on a primary key.

The script raises an exception unless the counts, exact totals and four classifications match this contract. It then replaces the temporary target rows with the source rows and asserts three unchanged rows and zero discrepancies. This repair is only a lab reset, not a production remediation recipe.

What the output means​

The first result set lists the four classified keys. The second prints the repaired classification counts. The final rollback removes the temporary objects and all lab changes. A successful SQL run demonstrates the fixture's PostgreSQL behavior; it is not a DataDios workflow execution report.

To rehearse the product workflow, use separately prepared, disposable persisted tables visible to your DataDios connections. Session-local temporary tables are not visible to a separate DataDios connection. Follow Data Source Diff, select the order_id key, and compare the resulting categories with this fixture. Record that product run separately; do not present the SQL-only result as product evidence.

Take the lesson to your migration​

Download the sample reconciliation report and checklist. Replace the synthetic scope with your actual table mappings, cutoffs, keys, transformations and owners. Add null, decimal and timestamp edge cases relevant to your data; this three-row fixture does not cover them all.

Return to the validation kit for the browser CSV demonstration or choose the Databricks and SQL Server to PostgreSQL playbooks. Your actual source and target configuration requires its own live validation.

Review the evidence your migration needs