Skip to content

feat!: creates and drops follow what an object says it needs - #196

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
feat/195-order-by-dependency
Nov 25, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
feat/195-order-by-dependency

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #195

Slice B of #115 (decided 2026-11-25), after slice A (#145).

Problem

Creates were ordered by placement and then by the model's order, and drops the other way round. Dependency.SchemaObject says an object needs another, and nothing kept that order: a trigger whose stored key sorts before its function's was created before it. The dependency held an owner and a name and no scope, so it could not say which table's object it means.

Change

  • Dependency.SchemaObject(Owner, Scope, Name). Which object is needed is the three together, as its descriptor says them.
  • Within a phase a create comes after the creates of what it needs and a drop before their drops, whatever the placement and the model's order say. What needs nothing keeps the order it had. The model's order is the order of the stored keys, not the one written.
  • Refused: objects that need each other in a circle, with their names; an object created before the tables that needs one created after them; and, in the context's own model only, a dependency on an object the model does not declare.
  • The kernel's sample contract has two kinds that need other objects, a routine created after the tables and a type created before them (DependencyOrderTests).
  • The second provider's audit test turned over: A_dependency_on_an_index_says_which_tables_index_it_means.

Not here:

  • A place among EF Core's operations, such as a create behind the EnsureSchema of its schema: slice C.
  • An object that stays while what it needs is dropped and created again. Nothing looks at that; on PostgreSQL the drop of a function a trigger uses is refused by the server.
  • Nothing that ships states a Dependency.SchemaObject yet. The row guard (RowGuard: delete guards as declared triggers, with one raise-only function #47) is the first.

Tests

Offline: 771 (kernel), 199 (PostgreSQL package), 90 (second provider); the API probes: 127. Live: 4 and 76 on PostgreSQL 16 and on 18, 86 on SQL Server 2022. The consumer smoke test: 47 rows. The live suites, the probes and the smoke test ran before the last two tests were added; nothing under src/ changed after them.

Ten rules were changed in turn and a test failed for each:

Changed Fails
Creates after the tables in the order they had A_chain_is_created_from_its_foot_and_dropped_from_its_head, the circle's test
Drops before the tables in the order they had A_chain_is_created_from_its_foot_and_dropped_from_its_head
Creates before the tables in the order they had What_is_created_before_the_tables_cannot_need_what_is_created_after_them
Drops after the tables in the order they had What_tables_are_made_of_is_ordered_among_itself, after a chain of three replaced the pair the first run showed held nothing
A type may need a routine What_is_created_before_the_tables_cannot_need_what_is_created_after_them
An undeclared dependency passes two
A snapshot is held to its dependencies too A_dependency_on_an_object_the_model_does_not_declare_is_refused_in_the_contexts_own_model
The scope does not count An_object_of_the_same_name_in_another_scope_is_not_the_one_that_is_needed
The owner does not count An_object_of_the_same_name_of_another_owner_is_not_the_one_that_is_needed, added after the first run showed nothing held it
A circle is taken in the order given Objects_that_need_each_other_in_a_circle_are_refused_with_their_names

breaking: Dependency.SchemaObject has a third member, in the contract (SK9001).

🤖 Generated with Claude Code

Dependency.SchemaObject takes the object's scope beside its owner and its
name: a name alone does not say which object is meant where names are
taken within a table.

Within a phase a create comes after the creates of what it needs and a
drop before their drops, whatever the placement and the model's order
say. What needs nothing keeps the order it had.

Refused: objects that need each other in a circle, an object created
before the tables that needs one created after them, and, in the
context's own model, a dependency on an object the model does not
declare.

Closes #195

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 25, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request breaking Changes an answer or a signature package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring labels Nov 25, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 7be0ce3 into main Nov 25, 2026
11 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/195-order-by-dependency branch November 25, 2026 13:58
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 breaking Changes an answer or a signature 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.

Timeline, slice B: SchemaKit's creates and drops are ordered by Dependency.SchemaObject, which gains the object's scope

1 participant