Skip to content

Add post-migration validation scripts for Cosmos DB to SQL migration#99

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/generate-post-migration-validation-scripts
Draft

Add post-migration validation scripts for Cosmos DB to SQL migration#99
Copilot wants to merge 3 commits into
mainfrom
copilot/generate-post-migration-validation-scripts

Conversation

Copilot AI commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Description

Post-migration validation suite: SQL scripts + PowerShell runner to verify data integrity, row counts, and performance after Cosmos DB → SQL migration.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Documentation update

Changes Made

  • Scripts/PostMigration/01-RowCountValidation.sql — Compares expected vs actual row counts per table with configurable tolerance, PASS/FAIL/WARNING per table
  • Scripts/PostMigration/02-DataIntegrityChecks.sql — FK orphan detection, index/PK existence, CHECKSUM_AGG per table, NOT NULL compliance
  • Scripts/PostMigration/03-SampleDataComparison.sql — First/last N rows per table (PK-ordered), column type summary, empty table warnings
  • Scripts/PostMigration/04-PerformanceBaseline.sql — Space usage, index usage stats, fragmentation, scan timing, wait stats, missing index suggestions
  • Scripts/PostMigration/RunAllValidations.ps1 — Orchestrates all scripts, generates per-script + consolidated reports, supports Windows/SQL auth, --SkipScripts, exit code 0/1
  • docs/post-migration-validation.md — Usage guide, script details, common issues, integration workflow
  • .gitignore — Added ValidationResults/

Testing

  • I have tested these changes locally
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested the command-line interface with various scenarios

Cosmos DB Testing

  • Tested with single database analysis
  • Tested with multi-database analysis
  • Tested report generation (Excel and Word)
  • Tested with different authentication methods
  • Tested error handling scenarios

Documentation

  • I have updated the documentation accordingly
  • I have updated the README if needed
  • I have updated command-line help text if needed

Security Considerations

  • No sensitive data is hardcoded
  • Authentication follows Azure best practices
  • No secrets in configuration files
  • Dependencies are up to date and secure

All dynamic SQL uses QUOTENAME() for identifier injection prevention. PowerShell credentials use ConvertTo-SecureString.

Screenshots (if applicable)

N/A — script-only changes, no UI.

Additional Notes

Scripts are standalone SQL files runnable via sqlcmd or Invoke-Sqlcmd. The 01-RowCountValidation.sql requires populating @ExpectedCounts from the assessment report before execution. All other scripts auto-discover tables via sys.tables.

Original prompt

This section details on the original issue you should resolve

<issue_title>Generate post-migration validation scripts</issue_title>
<issue_description>## Description
Create automated SQL scripts to validate migration success and data integrity.

Tasks

  • Row count comparison queries (Cosmos vs SQL)
  • Checksum validation scripts (sample data verification)
  • Sample data comparison (first/last N rows)
  • Foreign key integrity checks
  • Index existence validation
  • Performance baseline queries
  • Generate validation report template
  • PowerShell script to run all validations

Generated Files

  • Scripts/PostMigration/01-RowCountValidation.sql
  • Scripts/PostMigration/02-DataIntegrityChecks.sql
  • Scripts/PostMigration/03-SampleDataComparison.sql
  • Scripts/PostMigration/04-PerformanceBaseline.sql
  • Scripts/PostMigration/RunAllValidations.ps1

Acceptance Criteria

  • Scripts validate all migrated tables
  • Clear pass/fail results for each validation
  • Automated reporting of discrepancies
  • Documentation on how to run validations

Related Issues

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 20, 2026 19:03
- 01-RowCountValidation.sql: Row count comparison with configurable tolerance
- 02-DataIntegrityChecks.sql: FK integrity, index/PK validation, checksums, NULL compliance
- 03-SampleDataComparison.sql: First/last N rows per table, data type summary
- 04-PerformanceBaseline.sql: Space usage, index stats, fragmentation, wait stats
- RunAllValidations.ps1: PowerShell orchestrator with consolidated reporting
- docs/post-migration-validation.md: Usage guide and integration documentation
- .gitignore: Add ValidationResults/ to ignored paths

Co-authored-by: JoshLuedeman <6021644+JoshLuedeman@users.noreply.github.com>
…nsistency, docs improvement

Co-authored-by: JoshLuedeman <6021644+JoshLuedeman@users.noreply.github.com>
Copilot AI changed the title [WIP] Create automated SQL scripts for post-migration validation Add post-migration validation scripts for Cosmos DB to SQL migration Feb 20, 2026
Copilot AI requested a review from JoshLuedeman February 20, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate post-migration validation scripts

2 participants