Skip to content

Reduce migration complexity and add 49 boundary regression tests - #195

Merged
jogibear9988 merged 1 commit into
masterfrom
codex/reduce-migration-risk
Sep 23, 2026
Merged

jogibear9988 merged 1 commit into
masterfrom
codex/reduce-migration-risk

Conversation

@jogibear9988

Copy link
Copy Markdown
Member

This follow-up adds 49 behavioral tests and reduces migration risk in SQL preview, catalog parsing, and SQLite schema reconstruction.

Behavior changes

  • SQLite fallback column removal prepares all incoming foreign-key changes before issuing DDL, then rebuilds affected tables in one transaction. A parent rebuild failure now restores previously rebuilt children. Caller-owned transactions remain open for the caller to commit or roll back.
  • Column removal recognizes case-insensitive references and removes self-references to the deleted column without losing surviving data.
  • SQL preview reuses dialect identifier quoting, supporting spaces, dotted column names, and already-quoted qualified table names.
  • Schema-scoped GetColumns returns COLUMN_NAME rather than TABLE_NAME.
  • Constraint metadata reading separates dialect query selection, row grouping, and constraint creation. Alias lookup replaces repeated string branches; query SQL remains unchanged. Literal formatting uses an explicit numeric type allowlist, preserving unsupported-type rejection and invariant formatting.

Validation

All 1,149 local unit/SQLite tests pass (49 added). Seven new regression cases failed before the fixes and passed afterward. The tests include injected rebuild failure, caller rollback, self-references, actual SQLite execution of preview SQL, numeric boundaries under de-DE culture, catalog key ordering/type aliases, and reader disposal on errors.

Comparable local Coverlet/ReportGenerator results:

Metric Before After
Covered lines 5,918 / 10,543 (56.13%) 6,058 / 10,558 (57.37%)
Covered branches 2,608 / 5,230 (49.87%) 2,657 / 5,168 (51.41%)
Literal complexity / CRAP 44 / 137 24 / 24
RemoveColumn complexity / CRAP 70 / 133 34 / 34
Constraint Read complexity / CRAP 76 / 5,852 2 / 2

Extracted helpers are included in review: CatalogQuery has complexity 20 / CRAP 91, CreateConstraint and ReadConstraints each 8 / 8; SQLite native eligibility is 18 / 18, validation 14 / 15, and transaction orchestration 10 / 10. Complexity reduction at entry points includes responsibility separation; it does not mean those helper paths disappeared.

The downloaded merged CI report had 86.10% line and 78.63% branch coverage. It includes external-database suites, whereas these before/after measurements use the same local unit/SQLite filter. Updated merged coverage requires CI; these percentages must not be compared as a regression from 86.10%.

Local commands: dotnet test src/Migrator.Tests/Migrator.Tests.csproj --no-restore with the existing external-database category exclusions, XPlat Code Coverage and .github/coverage.runsettings; NUnit.NumberOfTestWorkers=0. git diff --check passes. Existing build warnings remain.

Add 49 behavioral cases covering culture-independent SQL literals, quoted
identifiers, schema-scoped metadata, constraint aliases and composite order,
reader cleanup, SQLite self references, and caller-owned transactions.

Make fallback column removal prepare all dependency changes before DDL and
rebuild related tables atomically. Preserve dependent constraints and rows
when rebuilding the parent fails; handle column references case insensitively.
Reuse dialect quoting in preview and return COLUMN_NAME from GetColumns.

Separate catalog query selection from parsing and use explicit lookups for
constraint aliases and numeric literal types. Reduce Literal complexity from
44 to 24, RemoveColumn from 70 to 34, and the largest constraint-reading
method from 76 to 20 (including extracted helpers).

Validation: all 1,149 local unit/SQLite tests pass. Seven new regression cases
failed before fixes. Comparable local coverage: lines 56.13% -> 57.37%,
branches 49.87% -> 51.41%. Full external-database coverage awaits CI.
Copilot AI lite review requested due to automatic review settings September 23, 2026 16:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jogibear9988
jogibear9988 merged commit 2605e63 into master Sep 23, 2026
14 checks passed
@jogibear9988
jogibear9988 deleted the codex/reduce-migration-risk branch September 23, 2026 16:13
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.

2 participants