Skip to content

feat: the planner's first slice, declarations on both sides matched, planned and ordered around EF Core's operations - #64

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
feat/63-planner-first-slice
Nov 12, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
feat/63-planner-first-slice

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #63

The first slice of #24, which stays open.

Problem

The host splices what an ISchemaOperationPlanner returns around the inner differ's operations, and the kernel's only planner was NoSchemaOperations. A stored declaration never became a statement outside the tests' stand-in.

Change

Migrations/Internal/SchemaOperationPlanner.cs, internal, in place of NoSchemaOperations:

  • Reads both sides the same way: every declaration on every entity type through its contributor, every descriptor through the kernel's resolver. The kernel reads a contributor's declarations through an internal IDeclarationSource, which SchemaContributor<,> implements; the registry takes no contributor that does not derive from it (A contributor that implements ISchemaContributor directly passes the base class's refusals by #48).
  • Matches (plan, 3.6): equal descriptors of one contributor are one object; the rest pair on kind, scope and name, then on equality but for the name; what is left is drops and creates.
  • Asks Plan per pair: None adds nothing, InPlace the statements written, Rebuild a drop and a create.
  • Orders: drops, EF Core's operations untouched, in-place statements, creates; contributors by placement. A BeforeTables contributor is created before and dropped after, and a Rebuild from one is refused.
  • Refuses a declaration whose owner has no contributor, on either side.
  • Resolves nothing until a declaration is met: a context that declares nothing never builds the dialect.

Found while writing the checks below: two contributors may share a descriptor type, and plain descriptor equality took a unique index and a plain index of the same name and column for one object. Equality now asks for the same contributor, with a test.

Two existing tests changed because scaffolding now runs the real planner: SnapshotRoundTripTests registers the contributor its declarations belong to, and declares its trigger under epoch 1 (another epoch surviving the stored form stays with DeclarationCodecTests).

Not here (stays in #24)

  • EF Core's operations as BaseChange, and ImpactOf. Until then a descriptor that reads a renamed column or table is rebuilt, and an object the database loses while both models declare it unchanged (SQLite's table rebuild) is not created again. No contributor for SQLite should ship before that slice; CLAUDE.md says so.
  • The table of every MigrationOperation type and the error for one outside it.
  • Ordering by Dependency.SchemaObject.
  • Deleting the stand-in planner in Harness/TestKit.cs, which the host's own tests still use.

Tests

Kernel tests without a server, on SDK 11.0.100 in the checkout: 326 before, 343 after. Probes: 125 pass. The PostgreSQL integration tests did not run locally; CI runs them.

SchemaOperationPlannerTests drives the real host with three sample contributors (after the tables at 5 and at 10, and before the tables). A model against its own compiled snapshot gives no operation on Npgsql, SQL Server and SQLite, and the same test shows it is not vacuous: from no model, and to no model, each declaration is a statement.

Each rule undone in a scratch copy:

Undone Fails
Equal descriptors are not taken out the snapshot test (3 providers), the operational-difference test
Equality across contributors Equal_descriptors_of_two_contributors_are_two_objects
No pairing by name the same-name test, the before-tables test
No pairing but for the name the rename test, the None test, the in-place-order test, the before-tables test
A rebuild does not drop / does not create the rebuild test (each)
A rebuild before the tables is allowed the before-tables test
Drops in creation order / creates in reverse the placement test (each)
In-place statements after creates the in-place-order test
Before-tables objects treated like the others the placement test
An owner without a contributor is skipped the no-contributor test
The dialect is built for every plan A_context_that_declares_nothing_never_builds_the_dialect

🤖 Generated with Claude Code

…planned and ordered around EF Core's operations

SchemaOperationPlanner replaces NoSchemaOperations. It reads every
declaration of the source and the target model through its contributor and
the kernel's resolver, takes equal descriptors of one contributor for one
object, pairs the rest by kind, scope and name and then by equality but for
the name, asks the contributor for its plan, and orders the statements:
drops, EF Core's operations, in-place statements, creates, by placement.

A declaration whose owner has no contributor is refused. A context that
declares nothing never builds the dialect.

EF Core's operations are not read yet; that stays in #24.

Closes #63

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 12, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring labels Nov 12, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 7b81e3b into main Nov 12, 2026
7 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/63-planner-first-slice branch November 12, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring enhancement New feature or request package/core Affects CodoMetis.EFCore.SchemaKit (the kernel)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Planner, first slice: declarations on both sides become descriptors, matched, planned and ordered around EF Core's operations

1 participant