Inferensys

Prompt

Data Reconciliation Post-Migration Prompt

A practical prompt playbook for using Data Reconciliation Post-Migration Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, ideal user, required inputs, and operational boundaries for the Data Reconciliation Post-Migration Prompt.

This prompt is designed for data engineers and backend platform teams who have just executed a database migration and need to confirm that data integrity survived the operation. The job-to-be-done is producing a structured, executable reconciliation checklist—row counts, checksums, distribution checks, and orphan detection—that validates the target state against the source state. It is not a migration review prompt for pre-flight risk assessment; use the Migration Rollback Safety Review or Schema Drift Detection prompts before deployment. This prompt assumes the migration has already run and you are now in the verification window.

The ideal user has access to both source and target database environments, can execute validation SQL, and can feed the results back into the prompt for interpretation. Required context includes the migration scope (which tables, columns, or transformations were applied), expected row counts or tolerance thresholds, and any known intentional differences such as filtered rows or recalculated columns. Without this context, the prompt will generate generic checks that may flag expected differences as failures, wasting triage time. Do not use this prompt when the migration is still in planning, when you lack query access to both environments, or when the migration involved opaque ETL tools whose internal state you cannot inspect.

The prompt produces a checklist, not a pass/fail verdict. It generates validation queries and interpretation guidance, but the harness must execute those queries and feed results back for analysis. In high-stakes migrations—financial ledgers, healthcare records, user deletion pipelines—always pair the prompt output with human review of flagged discrepancies. The prompt can identify mismatches, but it cannot decide whether a mismatch is an acceptable business deviation or a data corruption incident. Wire the output into a reconciliation runbook that logs every check, its result, and the human sign-off before closing the migration window.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Data reconciliation after migration requires structured inputs, executable validation, and clear boundaries between what the prompt interprets and what the harness must verify.

01

Good Fit: Structured Source-Target Comparison

Use when: you have completed a migration and can provide row counts, checksums, schema definitions, and distribution samples from both source and target systems. The prompt excels at interpreting these structured inputs and generating a prioritized reconciliation checklist. Guardrail: always feed the prompt actual query results, not assumptions about what the migration should have produced.

02

Bad Fit: Live Migration Debugging

Avoid when: the migration is actively failing, throwing errors, or producing partial results. This prompt assumes the migration has completed and needs validation, not real-time triage. Guardrail: route active failures to the Incident Root Cause Analysis prompt or Migration Rollback Safety Review prompt instead. Do not use reconciliation prompts to diagnose in-flight errors.

03

Required Inputs: Query Results, Not Guesses

What to watch: the prompt cannot run SQL or connect to databases. It interprets results you provide. Missing or estimated inputs produce unreliable checklists. Guardrail: the harness must execute row count queries, checksum functions, distribution bucketing, and orphan detection SQL before calling the prompt. Feed structured results, not raw table dumps.

04

Operational Risk: False Confidence in Completeness

What to watch: the prompt may produce a thorough-looking checklist that misses reconciliation gaps if the harness did not provide complete inputs. A clean checklist does not mean the data is clean. Guardrail: require a pre-flight validation step that confirms all required input categories (counts, checksums, distributions, orphans) are present before generating the checklist. Log missing categories as explicit risks.

05

Scale Boundary: Large-Scale Migrations

What to watch: for migrations with hundreds of tables or billions of rows, the prompt's checklist can become unwieldy or miss cross-table dependency issues. Guardrail: partition reconciliation by table group or dependency boundary. Run the prompt per partition and aggregate results. Use the Cross-Schema Dependency Analysis prompt for multi-schema migrations before running reconciliation.

06

Human Review: Anomaly Interpretation

What to watch: the prompt can flag distribution drift, orphan records, and checksum mismatches, but it cannot determine root cause or business impact. Guardrail: every flagged anomaly must route to a human reviewer who understands the migration logic and business rules. The prompt output is a triage list, not a verdict. Escalate any checksum mismatch or orphan count above zero.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for generating a structured data reconciliation checklist after a migration has been executed.

This prompt template is the core instruction set you'll send to the model. It is designed to be wired into an automated harness that first executes validation SQL against the source and target databases, then feeds the results into this prompt for interpretation. The model's job is not to run queries, but to analyze the provided row counts, checksums, and distribution samples to produce a structured reconciliation report with a clear pass/fail status for each check.

text
You are a senior data engineer validating the results of a database migration. Your task is to analyze the provided reconciliation data and produce a structured report.

## INPUT DATA
- Source Database Snapshot: [SOURCE_STATS]
- Target Database Snapshot: [TARGET_STATS]
- Row Count Comparison Results: [ROW_COUNT_DIFF]
- Checksum Validation Results: [CHECKSUM_RESULTS]
- Distribution Drift Samples: [DISTRIBUTION_SAMPLES]
- Orphan Record Detection Results: [ORPHAN_RESULTS]

## OUTPUT SCHEMA
Return a single JSON object with the following structure:
{
  "overall_status": "PASSED" | "FAILED" | "INCONCLUSIVE",
  "summary": "A concise, one-paragraph executive summary of the reconciliation outcome.",
  "checks": [
    {
      "check_name": "string",
      "status": "PASSED" | "FAILED" | "WARNING",
      "expected": "string describing the expected state",
      "actual": "string describing the observed state",
      "delta_description": "A precise description of the discrepancy, or null if passed.",
      "severity": "CRITICAL" | "HIGH" | "MEDIUM" | "LOW",
      "recommendation": "A clear, actionable next step to resolve the issue, or null if passed."
    }
  ],
  "requires_rollback": true | false,
  "rollback_reason": "A justification for the rollback recommendation, or null if rollback is not required."
}

## CONSTRAINTS
- Do not invent or assume data not present in the input. If a check cannot be evaluated due to missing input, set its status to "WARNING" and explain why.
- A checksum mismatch on any table must result in an overall_status of "FAILED" and requires_rollback set to true.
- A row count discrepancy greater than [ROW_COUNT_TOLERANCE]% must result in an overall_status of "FAILED".
- Distribution drift is a warning unless it exceeds [DRIFT_THRESHOLD]%, in which case it is a failure.
- Orphan records must be flagged as "CRITICAL" severity.
- If the overall_status is "INCONCLUSIVE", explain exactly what additional data or checks are needed to reach a conclusion.

To adapt this template, replace the square-bracket placeholders with actual data from your reconciliation harness. [SOURCE_STATS] and [TARGET_STATS] should be structured summaries including table lists, row counts, and schema versions. [ROW_COUNT_TOLERANCE] and [DRIFT_THRESHOLD] should be numeric values representing your team's acceptable deviation percentages (e.g., 0 for exact match, 0.5 for minor drift). Before putting this into production, run it against a known migration outcome—both a clean pass and a deliberate failure—to calibrate the severity and rollback logic. If the model ever recommends a rollback, route that decision to a human for final approval before executing any destructive action.

IMPLEMENTATION TABLE

Prompt Variables

Placeholders required by the Data Reconciliation Post-Migration Prompt. Wire these into your harness before execution.

PlaceholderPurposeExampleValidation Notes

[SOURCE_CONNECTION_STRING]

Connection details for the source database

postgresql://user:pass@source-host:5432/sourcedb

Must be a valid connection string. Harness must test connectivity before prompt execution.

[TARGET_CONNECTION_STRING]

Connection details for the target database

postgresql://user:pass@target-host:5432/targetdb

Must be a valid connection string. Harness must test connectivity before prompt execution.

[MIGRATION_SCOPE]

List of schemas or tables included in the migration

['public.users', 'public.orders', 'public.payments']

Must be a non-empty array of fully qualified table names. Harness must verify each table exists in both source and target.

[RECONCILIATION_RULES]

Custom business rules for row-level comparison

{"ignore_columns": ["updated_at", "last_login"], "tolerance": {"amount": 0.01}}

Must be a valid JSON object. Null allowed if no custom rules. Harness must validate JSON schema before passing to prompt.

[ROW_COUNT_RESULTS]

Pre-computed row counts from source and target

{"public.users": {"source": 10000, "target": 9998}, "public.orders": {"source": 50000, "target": 50000}}

Harness must execute COUNT(*) on both sides and inject results. Null counts indicate query failure and must abort the prompt.

[CHECKSUM_RESULTS]

Pre-computed checksums for each table

{"public.users": {"source": "a3f2b1c9", "target": "a3f2b1c9"}, "public.orders": {"source": "d4e5f6a7", "target": "x1y2z3w4"}}

Harness must compute checksums using a consistent algorithm. Mismatched checksums must be flagged for row-level drill-down.

[ORPHAN_DETECTION_QUERIES]

SQL queries that detect orphaned child records

["SELECT o.id FROM target.orders o LEFT JOIN target.users u ON o.user_id = u.id WHERE u.id IS NULL"]

Harness must execute each query and inject result counts. Empty result sets are valid. Query failures must be reported as reconciliation errors.

[DISTRIBUTION_DRIFT_RESULTS]

Statistical comparison of column distributions

{"public.orders.amount": {"source_mean": 150.23, "target_mean": 150.19, "drift_pct": 0.03}}

Harness must compute distributions for numeric columns. Drift exceeding configurable threshold must be highlighted. Null allowed if no numeric columns exist.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the reconciliation prompt into a data pipeline with validation, retries, and human review.

This prompt is designed to be the final interpretation layer in a multi-step reconciliation pipeline. It should not be called directly with raw migration metadata. Instead, the application harness must first execute the validation SQL queries (row counts, checksums, distribution checks, orphan detection) against both the source and target databases, collect the results, and format them into the structured [RECONCILIATION_DATA] input block. The prompt then interprets discrepancies, classifies severity, and generates a human-readable report. This separation ensures the model reasons over concrete evidence rather than guessing about data state.

The implementation should follow a strict execute → validate → interpret → review loop. First, run all reconciliation queries with timeouts and error handling; a failed query should not block the entire report but must be flagged as query_status: failed in the input. Second, validate that the harness output conforms to the expected input schema before calling the model—reject malformed measurement blocks early. Third, call the model with a temperature of 0.0–0.2 to minimize variance in severity classification. Fourth, parse the model's JSON output and validate it against the [OUTPUT_SCHEMA] before surfacing it. Any output that fails schema validation should trigger a single retry with the validation error appended to the [CONSTRAINTS] block. If the retry also fails, escalate the raw reconciliation data and partial output to a human operator via a review queue rather than silently dropping findings.

For production deployments, log every reconciliation run as an immutable record: input snapshot, model response, validation pass/fail, and human review decision. This audit trail is critical for compliance workflows (SOC2, HIPAA) where data integrity verification must be demonstrable. Avoid wiring this prompt directly into an automated rollback decision. The model's severity classification informs a human decision; it does not replace it. The most common production failure mode is stale reconciliation queries that reference dropped columns or renamed tables after a schema change—build a pre-flight check that validates query executability before feeding results to the model.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the structure, types, and validation rules for the reconciliation report generated by the Data Reconciliation Post-Migration Prompt. Use this contract to parse and validate the model's output before surfacing results.

Field or ElementType or FormatRequiredValidation Rule

reconciliation_summary

Object

Must contain 'overall_status' (enum: PASSED | FAILED | WARNING) and 'compared_at' (ISO 8601 timestamp).

row_count_comparison

Object

Must contain 'source_count' (integer), 'target_count' (integer), 'delta' (integer), and 'delta_percentage' (float). 'delta' must equal target_count minus source_count.

checksum_validation

Array of Objects

Each object must have 'table_name' (string), 'source_checksum' (string), 'target_checksum' (string), and 'match' (boolean). Array must not be empty.

distribution_drift_checks

Array of Objects

If present, each object must have 'column_name' (string), 'drift_detected' (boolean), and 'drift_summary' (string). Null allowed if no distribution checks were configured.

orphan_record_detection

Array of Objects

Each object must have 'child_table' (string), 'parent_table' (string), 'fk_column' (string), 'orphan_count' (integer), and 'sample_ids' (array of strings). Array may be empty if no orphans found.

validation_queries_executed

Array of Strings

Each string must be a valid SQL query that was executed. Array must not be empty. Queries must be sanitized of sensitive literals.

findings

Array of Objects

Each object must have 'severity' (enum: CRITICAL | HIGH | MEDIUM | LOW), 'category' (string), 'description' (string), and 'recommendation' (string). Array may be empty if no issues found.

human_review_required

boolean

Must be true if 'overall_status' is FAILED or any finding has severity CRITICAL. Otherwise may be false.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first in data reconciliation prompts and how to guard against it before production.

01

Schema Drift Between Source and Target

What to watch: The prompt assumes column names, types, or nullability from the migration spec, but the actual target schema has diverged due to manual hotfixes or environment differences. The model generates validation queries that fail at runtime or silently return wrong results. Guardrail: Feed live schema introspection output from both source and target into the prompt context. Never rely on migration spec alone. Validate that every column referenced in generated SQL exists in the actual catalog before execution.

02

Silent Truncation in Checksum Comparisons

What to watch: The model generates checksum queries using functions like MD5() or CRC32() without accounting for collation differences, trailing whitespace, or type coercion. Two rows appear identical in checksum but differ in actual content, or vice versa. Guardrail: Include explicit collation and trimming rules in the prompt constraints. Require the harness to run both checksum and row-by-row diff for a sample of mismatches. Flag any checksum match where row-level comparison shows divergence.

03

Orphan Detection Misses Soft References

What to watch: The prompt generates orphan checks only for explicit foreign key constraints. Application-level relationships, soft references (string-based IDs), and cross-database dependencies are invisible to the model unless explicitly described. Guardrail: Require the prompt input to include a manifest of known application-level relationships beyond DDL constraints. Generate orphan queries for both hard FK and documented soft references. Log any unmapped relationship as a review item.

04

Row Count Mismatch Without Root Cause

What to watch: The prompt correctly identifies a row count delta but attributes it to the wrong cause—filter conditions, join semantics, or batch boundaries—leading the engineer to investigate a false lead. Guardrail: Structure the output to require segmented row counts (by partition, date range, or batch ID) rather than a single aggregate. When a delta exists, the prompt must generate diagnostic queries that isolate which segment diverged before proposing a cause.

05

Distribution Drift Confused With Data Corruption

What to watch: The model flags a legitimate distribution change (e.g., new product category added during migration window) as a data integrity failure, generating false-positive alerts that erode trust in the reconciliation process. Guardrail: Include a temporal baseline in the prompt—distribution snapshots from before the migration window. Require the model to distinguish between expected drift (changes that also appear in source pre-migration trends) and migration-induced anomalies. Flag only the latter as actionable.

06

Validation Query Timeout on Large Tables

What to watch: The model generates unbounded SELECT COUNT(*) or full-table checksum queries against billion-row tables without sampling or partitioning. The harness executes them, hits a timeout, and the reconciliation job fails silently or blocks the pipeline. Guardrail: Add explicit constraints in the prompt requiring partition-key filtering, row limits, or sampling for tables above a configurable size threshold. The harness must wrap generated queries with statement timeouts and report any query that exceeds the limit as a partial result requiring manual review.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of the reconciliation report before accepting it as a release gate. Each criterion should be checked programmatically where possible, with human review required for business-logic interpretation.

CriterionPass StandardFailure SignalTest Method

Row Count Match

Source and target row counts match exactly for all tables listed in [MIGRATION_SCOPE]

Any table shows a non-zero row delta in the reconciliation summary

Parse the output JSON. For each table in the reconciliation block, assert source_row_count equals target_row_count. Fail on any mismatch.

Checksum Validation

All checksum comparisons return 'match' for tables where full-content verification is specified

Any checksum field shows 'mismatch' or 'error'

Iterate over checksum_results array. Assert every entry has status equal to 'match'. Flag any 'mismatch' or 'error' for human review.

Orphan Record Detection

Orphan detection queries return zero orphaned rows for all defined foreign key relationships

Any orphan query returns a count greater than 0

Parse orphan_checks array. Assert orphan_count equals 0 for every relationship. Non-zero counts require immediate escalation.

Distribution Drift Check

All distribution comparisons report drift within the [DRIFT_THRESHOLD] percentage

Any column shows drift exceeding the configured threshold

For each entry in distribution_drift, assert drift_percentage is less than or equal to [DRIFT_THRESHOLD]. Flag threshold violations for analyst review.

Schema Completeness

Every table and column listed in [EXPECTED_SCHEMA] appears in the reconciliation report

A table or column from the expected schema is missing from the output

Diff the set of tables and columns in [EXPECTED_SCHEMA] against the output. Assert empty diff. Missing elements indicate incomplete reconciliation.

Validation SQL Executability

All validation SQL statements in the report are syntactically valid and reference real objects

Any SQL statement fails to parse or references a non-existent table or column

Execute each validation SQL statement in a dry-run or EXPLAIN mode against the target database. Assert no parse errors or invalid object references.

Actionable Remediation

Every failure entry includes a specific remediation query or rollback step

A failure entry has an empty or null remediation field

For each entry in failures array, assert remediation_sql is not null and is not an empty string. Missing remediation steps block automated recovery.

Human Approval Gate

Report includes a clear summary block with overall pass/fail status and items requiring human decision

Summary block is missing, or pass/fail status is ambiguous

Parse the summary object. Assert overall_status is present and equals 'pass', 'fail', or 'review_required'. Assert human_review_items is an array. Missing summary blocks prevent release automation.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single reconciliation check (row counts only). Remove checksum and distribution drift sections. Accept plain-text output without strict schema enforcement.

code
You are a data reconciliation reviewer. Given the following migration summary and row counts from [SOURCE_SYSTEM] and [TARGET_SYSTEM], identify any discrepancies and suggest next steps.

Migration Summary:
[MIGRATION_SUMMARY]

Source Row Count: [SOURCE_COUNT]
Target Row Count: [TARGET_COUNT]

Watch for

  • False confidence when row counts match but data differs
  • Missing checksum validation means silent corruption goes undetected
  • No structured output makes automated downstream processing impossible
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.