Language-agnostic SQL Server to PostgreSQL database migration skill using multi-tool redundancy. Covers assessment, migration, validation, Fabric integration, and data agent setup with 12 cross-validating tools.
This is the single source of truth for running the end-to-end database migration.
All orchestration lives here. docs/ only holds generated results.
Iterate to consensus. For each step:
| Input | Required | Default |
|---|---|---|
sourcePath | Yes | - |
sourceConnectionString | Yes | - |
targetConnectionString | No | auto-provisioned Azure PG |
demoDatabase | No | WideWorldImporters |
mssql_connect).pgsql_*).dab --version).agentsec --version).Tools: mssql_connect, mssql_list_tables, mssql_run_query, ora2pg, DAB, SSMS 22, sec-check
Output: docs/01-source-assessment.md, docs/tsql-incompatibility-report.md
Step 1.1: Schema Discovery (3-tool cross-validation)
| Tool | Action | Purpose |
|---|---|---|
| MSSQL ext | mssql_connect then mssql_list_tables then mssql_run_query on INFORMATION_SCHEMA | Ground truth schema inventory |
| ora2pg | ora2pg -t SHOW_REPORT | Independent complexity assessment (A/B/C score) |
| DAB | dab init --database-type mssql | Entity discovery / migration manifest |
Consensus gate: All 3 report same table count, column types, FK relationships.
Step 1.2: SP/Trigger/View Extraction
-- Run via mssql_run_query
SELECT
o.name AS object_name,
o.type_desc,
m.definition,
LEN(m.definition) AS definition_length
FROM sys.sql_modules m
JOIN sys.objects o ON m.object_id = o.object_id
ORDER BY o.type_desc, o.name;
Step 1.3: T-SQL Incompatibility Scan (24 patterns)
Scan all extracted definitions for:
Output: docs/tsql-incompatibility-report.md with every instance, location, severity, recommended fix.
Step 1.4: Performance Baseline
Capture SSMS 22 execution plans for key stored procedures. Record:
Step 1.5: Security Baseline
-- Run via mssql_run_query
SELECT name, type_desc, is_disabled FROM sys.sql_logins;
SELECT * FROM sys.server_permissions;
SELECT name, is_encrypted FROM sys.databases;
Also run: agentsec scan on any SQL scripts in the source path.
Mermaid Diagrams: Source ER diagram, SP dependency graph, incompatibility heatmap.
Tools: pgLoader, ora2pg, Copilot, sqlfluff, pgtap, PostgreSQL ext
Output: docs/02-migration-execution.md, docs/schema-optimization-logic.md
Step 2.1: pgLoader Dry Run
pgloader --dry-run pgloader.conf
Validate type mappings. Cross-check with ora2pg schema conversion output.
Step 2.2: Data Transfer
pgloader pgloader.conf
pgLoader CAST rules for WideWorldImporters:
NVARCHAR to TEXTBIT to BOOLEANDECIMAL to NUMERICDATETIME2 to TIMESTAMPTZUNIQUEIDENTIFIER to UUIDMONEY to NUMERIC(19,4)HIERARCHYID to TEXT (with ltree migration plan)GEOGRAPHY to PostGIS geographyStep 2.3: SP Translation (T-SQL to PL/pgSQL)
For each stored procedure:
Step 2.4: Incompatible Pattern Rewrites
For each HIGH/MEDIUM pattern from Phase 1.3:
Document the reasoning for each optimization in docs/schema-optimization-logic.md.
Mermaid Diagrams: Migration flow, type mapping table, SP transformation pipeline, schema optimization decision tree.
Tools: MSSQL ext + PG ext (side-by-side), pgtap, DAB, HammerDB, pgbench, sec-check
Output: docs/03-validation-report.md, tests/performance/results/trending.md
Step 3.1: Data Integrity (3-tool validation)
| Tool | Method | Pass Criteria |
|---|---|---|
| MSSQL ext + PG ext | Row counts per table, side-by-side | All tables match |
| Checksum queries | Hash-based comparison on key columns | Checksums match |
| DAB API regression | Same REST endpoints on both DBs then diff responses | 100% match |
Step 3.2: Functional Equivalence (3-tool validation)
| Tool | Method | Pass Criteria |
|---|---|---|
| pgtap | Unit tests for each migrated PL/pgSQL function | All pass |
| DAB REST | Same API calls, compare results | Identical output |
| Side-by-side queries | Same business question on both DBs | Same result set |
Step 3.3: Performance (before/after)
Run perf-001 through perf-010 test suite. Store results as timestamped JSON.
| Test | What It Measures |
|---|---|
| perf-001 | Paginated query |
| perf-002 | Point lookup |
| perf-003 | Insert with sequence |
| perf-004 | Update |
| perf-005 | Business-rule-heavy update (SP5 equiv) |
| perf-006 | Delete |
| perf-007 | Aggregation report |
| perf-008 | 50 concurrent connections (HammerDB) |
| perf-009 | Index hit vs seq scan ratio |
| perf-010 | Connection pooling throughput (PgBouncer) |
Iterate: Baseline then add indexes then rewrite cursors then enable PgBouncer then track improvement.
Step 3.4: Security (before/after)
Run sec-001 through sec-010 test suite:
Mermaid Diagrams: Validation flow, performance trending, security progression, migration readiness dashboard.
Tools: SqlPackage, MSSQL ext (to Fabric SQL DB), DAB, trivy
Output: docs/04-fabric-integration.md
Tools: MSSQL ext (Copilot Agent Mode to Fabric), DAB MCP, Fabric Portal
Output: docs/05-data-agent-setup.md
.github/workflows/migration-ci.yml runs on every PR:
All 8 pass = migration validated. Any fail = investigate and iterate.
docs/. No orchestration content in docs/.