Skip to content

feat: an object that follows EF Core's renames is compared under the new names, so a rename does not rebuild it - #70

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
feat/renames-under-follows
Nov 12, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
feat/renames-under-follows

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #69

The third slice of #24 and the rename part of #43. Both stay open for what is listed on them.

Problem

Impact.Follows was taken as "leave it". The source side of a diff was resolved under its own model's names, so an object on a renamed table, or one that reads a renamed column, differed from the target's and was dropped and created: a rebuild under a lock for a rename the database follows by itself (spike E, #20).

Change

  • Resolution/Internal/ModelSchemaResolver.cs takes ISchemaRenames. Under them Table is the table as the target names it, and a fragment's SQL and its dependencies take the target's column names. A default name is still built from the model's own table and columns (NamedAfter, and each part's name token).
  • Migrations/Internal/BaseChanges.cs is the ISchemaRenames of a diff: it already carried tables and columns forward for matching changes to dependencies.
  • Migrations/Internal/SchemaOperationPlanner.cs. ImpactOf is asked for every source object with the object as it is. When every rename that touches it is answered Follows, its declaration is resolved again under the renames, and that descriptor is matched against the target:
    • with an explicit name it equals the target's: nothing is written;
    • with a default name it differs in the name alone: the contributor's InPlace rename, after EF Core's operations, as EF Core renames its own indexes.
  • A drop names the object as it is before EF Core's operations (Resolved.Before), since drops run before them.
  • An answer other than Follows to a rename leaves the object compared as it was, which is the contributor's to plan as before.

A contributor is now asked about every source object an operation touches, also one that is dropped anyway.

Tests

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

Two tests that held the old behaviour are rewritten: An_object_on_a_renamed_table_is_dropped_and_created is now part of An_object_that_follows_a_rename_is_not_touched, and the Follows row of A_changed_object_is_not_planned_when_the_operation_decides expects EF Core's rename alone.

New: a renamed column, a renamed table and both leave an index with an explicit name alone; an index with a default name gets one ALTER INDEX … RENAME after EF Core's operations; an answer of Unaffected to a rename is compared as it was; a trigger rebuilt next to a table rename is dropped ON "Thing" and created ON "Things"; and at the resolver, under renames the SQL and the dependencies take the new names while the default name equals the one without renames.

Each rule undone in a scratch copy:

Undone Fails
The table is not carried forward the follows test, the default-name test, the resolver test
A column is not carried forward the same three, and the Follows row
A default name is built from the new table / the new column the default-name test, the resolver test (each)
Resolved again whatever the answer to a rename An_object_that_does_not_follow_a_rename_is_compared_as_it_was
A drop names the object as compared A_drop_names_the_object_as_it_is_before_ef_cores_operations
The renames are not handed to the resolver the follows test, the default-name test, the Follows row

One more was undone and nothing failed: not resolving again when the object is also lost or rebuilt around. Either way the same statements come out, so the condition is removed and not tested.

🤖 Generated with Claude Code

…new names, so a rename does not rebuild it

The resolver takes EF Core's renames for the source side of a diff: a
fragment's SQL and what it reads take the table and the columns as the
target names them, and a default name is still built from the source's own.

The planner asks ImpactOf with the object as it is. When every rename that
touches it is answered Follows, the declaration is resolved again under the
new names and that is matched against the target. An object with an
explicit name then equals the target's; one with a default name differs in
the name alone, which is the contributor's InPlace rename. A drop names the
object as it is before EF Core's operations.

Closes #69

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 05150bd into main Nov 12, 2026
7 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/renames-under-follows branch November 12, 2026 09:37
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.

Renames under Follows: the source side resolves under the names EF Core gives a renamed table and column, so what reads them is not rebuilt

1 participant