Skip to content

Tests: a SQL Server integration lane that applies migrations to a live server - #120

Merged
CaffeinatedCoder merged 3 commits into
mainfrom
tests/100-sqlserver-lane
Oct 20, 2026
Merged

CaffeinatedCoder merged 3 commits into
mainfrom
tests/100-sqlserver-lane

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #100

Stacked on #113 (#96) → #107 (#92) → #105 (#90). Merge in that order. The .NET workflow runs only on PRs into main/release/**, so this branch's CI is a workflow_dispatch run on the same commit. Once it targets main, the new job reports on the PR itself.

The trigger may change. A separate session is analysing selective CI across the repositories, so how and when this job runs may change after that analysis. The shape here is deliberately the plainest one: the same triggers and steps as Integration (PostgreSQL 18).

Problem

Nothing applied a SQL Server migration to a SQL Server. Every SQL Server test compared rendered SQL or the operation list, and that layer cannot see what the server refuses or accepts. Three 5.5.0 defects passed all of them:

Change

  • SqlServerIntegrationTests (TestCategory Integration and SqlServer):
    • The server: Testcontainers.MsSql 4.14.0 (same version as the PostgreSQL package) starts mcr.microsoft.com/mssql/server:2022-latest, with a database per test.
    • Diff and apply: it diffs with the SQL Server differ as migrations add does, and applies as database update does. The context's runtime services (UseSqlServerComplexIndexes()) render with the target model, and EF's IMigrationCommandExecutor runs the commands.
    • Read-back: sys.indexes, sys.index_columns and sys.partitions give type, uniqueness, filter, fill factor, compression, key order and direction, and included columns. It inserts rows to check what unique indexes refuse.
    • Covers:
  • CI: a job Integration (SQL Server 2022) in dotnet.yml beside the PostgreSQL one, with CI=true, so an unavailable container fails instead of going inconclusive. The PostgreSQL job now filters TestCategory!=SqlServer, and Pack waits for both. release.yml runs the full suite with CI=true, so the lane gates releases too.
  • Docs: CLAUDE.md and CONTRIBUTING.md name the second lane. CLAUDE.md adds the local caveat: the image is amd64 only and crashes under QEMU on Apple Silicon, so it needs Rosetta in the Docker VM (orb config set rosetta true on OrbStack).

Tests

Local: this Mac runs OrbStack with Rosetta off, and SQL Server 2022 crashes under QEMU there, so the class goes inconclusive locally as designed. The lane was verified on CI only.

Lane green: a dispatch run on this branch executed all 11 tests and passed them (trx counters: total=11 executed=11 passed=11).

Proof by revert, each a throwaway commit on a branch of its own (proof/100-revert-*, never main), with the workflow dispatched there:

Reverted Lane result
#84 (RequiresIndexRecreation → false) 10/11. ALTER COLUMN under a complex index applies: "The index 'ux_phone' is dependent on column 'phone'. ALTER TABLE ALTER COLUMN phone failed…"
#88 (ImplicitFilter → null) 10/11. The optional-complex test: filter null where ([Registration_Vin] IS NOT NULL) was expected
#90 (SQL Server differ as before #105) 9/11. Both #90 tests got a SqlException instead of a migrations add refusal: "Cannot create more than one clustered index on table 'customers'" and "…an index or statistics with name 'pk_customers' already exists"

The first #84 proof passed 11/11. The test widened the columns, and SQL Server allows widening an nvarchar under an index as a metadata-only change. It now shrinks them, and the proof above is the rerun.

Finding: a probe on another throwaway branch showed that index names differing only in case pass the name checks and fail at apply on SQL Server. Filed as #116.

Required check

Branch protection is unchanged. After this merges, add the job as a required check:

gh api -X POST repos/CaffeinatedCoder/EFCore.ComplexIndexes/branches/main/protection/required_status_checks/contexts -f 'contexts[]=Integration (SQL Server 2022)'

The same for release/5.x once it is cut, with main replaced by release/5.x in the path.

🤖 Generated with Claude Code

@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (harnesses, parity suites); no library code stacked Base is another open PR; merge in order, CI does not run until it targets main package/sqlserver Affects EFCore.ComplexIndexes.SqlServer area/indexes Complex-property, composite, unique and filtered indexes area/migrations The differs, snapshot format, EnsureCreated and design-time wiring labels Oct 20, 2026
CaffeinatedCoder and others added 2 commits October 20, 2026 08:26
… server (#100)

Nothing applied a SQL Server migration to a SQL Server: every SQL Server
test compared rendered SQL or the operation list, and #84, #88 and #90
each passed all of them while failing only on a server.

SqlServerIntegrationTests (TestCategory Integration and SqlServer) starts
mcr.microsoft.com/mssql/server:2022-latest through Testcontainers.MsSql,
creates a database per test, diffs with the SQL Server differ as
migrations add does and applies as database update does: the context's
runtime generator (UseSqlServerComplexIndexes()) renders with the target
model and EF's command executor runs it. It reads the result back from
sys.indexes, sys.index_columns and sys.partitions, and inserts rows to see
what unique indexes refuse. Covered: every whitelisted option property-
and entity-level, a DESC part, a placeholder filter, a unique index over an
optional complex property (#88), an index rename, a table rename, ALTER
COLUMN under a key and under an included column (#84), the clustered cases
and the key-name refusal of #90, and EnsureCreated.

CI: a job "Integration (SQL Server 2022)" beside the PostgreSQL one, with
CI=true; the PostgreSQL job now excludes TestCategory=SqlServer, and Pack
waits for both. Locally without a usable image the class goes
inconclusive; on Apple Silicon the amd64 image needs Rosetta (it crashes
under QEMU), noted in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing cannot fail (#100)

SQL Server allows widening an nvarchar under an index as a metadata-only
change, so the test passed with #84's fix reverted (proof run on a draft
branch). Shrinking is refused with Msg 5074, as a type or nullability
change is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder
CaffeinatedCoder force-pushed the tests/100-sqlserver-lane branch from 2cc0216 to 318a6f4 Compare October 20, 2026 06:26
@CaffeinatedCoder
CaffeinatedCoder force-pushed the tests/96-sqlserver-seeds branch from 981c13b to 01c1a52 Compare October 20, 2026 06:26
@CaffeinatedCoder
CaffeinatedCoder changed the base branch from tests/96-sqlserver-seeds to main October 20, 2026 06:40
@CaffeinatedCoder
CaffeinatedCoder merged commit 565e015 into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the tests/100-sqlserver-lane branch October 20, 2026 06:44
CaffeinatedCoder added a commit that referenced this pull request Oct 20, 2026
…eSql

The SQL Server lane (#120) pinned Testcontainers.MsSql 4.14.0 after this
bump was opened, so the two modules would resolve different versions of the
shared Testcontainers core.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/indexes Complex-property, composite, unique and filtered indexes area/migrations The differs, snapshot format, EnsureCreated and design-time wiring package/sqlserver Affects EFCore.ComplexIndexes.SqlServer stacked Base is another open PR; merge in order, CI does not run until it targets main tests Adds or changes tests only (harnesses, parity suites); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests: a SQL Server integration lane that applies migrations to a live server

1 participant