Repository navigation
Description
2026-11-25, where it stands. Slice A is merged: #145 and #193, PR #194. Slice B is in PR #196 (#195). Slice C, one ordered list with EF Core's operations, is at the gate of rc.1; slice D, a create behind SQLite's rebuild, comes with the first object SchemaKit creates on SQLite. Whether the row guard creates its trigger on SQLite in 11.0.0 is open on #47. This issue stays open for C and D.
Decided 2026-11-25 by the maintainer: the proposal below, as recommended. A and B for preview.2; Dependency.SchemaObject gains the object's scope; C moves to the gate of rc.1; D comes with the first object SchemaKit creates on SQLite. Whether the row guard creates its trigger on SQLite in 11.0.0 was not answered and stays open on #47. A is #145; B is a sub-issue of #111.
Proposal, 2026-11-25. A sentence that says "measured" names where; everything else is a recommendation. It proposes less than the issue below asks for, and says why.
Where the two lists stand today
A plan is Before and After, spliced around EF Core's operations. Of the four failures the issue names:
| Failure | Today |
|---|---|
| A name freed by a rename is free too late (#99) | Fixed for preview.1 by a point fix: such a rename is a rebuild (KeepInPlace). Correct on PostgreSQL 16 and 18 (RenameInPlaceTests, the live pair). The cost is a rebuild where a rename would do |
| A create placed before tables precedes its schema | Still so. Measured today with the kernel's sample domain on a table in a new schema: CREATE DOMAIN depot.weight AS integer;, then EnsureSchemaOperation, then CreateTableOperation. Nothing that ships is placed before tables |
The order Dependency.SchemaObject promises is not kept |
Still so: creates are ordered by placement and then by the model's order. The dependency holds an owner and a name and no scope, so it cannot say which table's object it means (the second provider's audit, A_dependency_on_an_index_cannot_say_which_tables_index_it_means) |
| SQLite's rebuild has no place a create can follow | Still so, and silent in three cases (#145, held as they are by the three Today_… tests) |
What EF Core does with an annotation on a SqlOperation is measured (spike D): migrations add writes it as .Annotation(…) on the migrationBuilder.Sql(…) call, the generator receives it in a script, an idempotent script and a bundle, and the migration's code is its only carrier. So it is a file format in consumers' repositories from the day it ships.
Proposed: four slices, and not all of them now
A. Refuse on SQLite what would be lost (#145). A create of an object attached to a table that the same migration rebuilds is refused at the diff, with the declaration and the operation named. One refusal in place of three silent losses and one failure at apply. No contract change. It goes when slice D places the create.
B. Order SchemaKit's own actions by Dependency.SchemaObject. A create comes after the creates of what it depends on and a drop before their drops, within the placement's phase; a cycle is refused with its members named. This needs the dependency to say which object it means: Dependency.SchemaObject gains the object's scope, (Owner, Scope, Name). That is a change to a case of a closed union of the contract, so it is the maintainer's decision. The row guard (#47), in the 11.0.0 milestone, is the first object that needs it: a trigger after its function.
C. One ordered list in place of two. The planner returns its statements interleaved with EF Core's operations, each with the names it takes and gives up, and the name check walks that list from the source's claims. First use: what is created before tables goes after the EnsureSchema of its schema. KeepInPlace becomes that walk and keeps its answer, a rebuild: moving a rename ahead of EF Core's operations would need the contributor to write its statement for the table as the source names it, which the contract does not ask today. Nothing public changes.
D. A statement that says what it is, and SQLite's create after the rebuild. Annotations on SchemaKit's SqlOperations (kind, object, whether it follows a rebuild), and the generator decorator moves such a create behind the rebuild. The annotations are permanent once a consumer's migration holds them.
What I recommend
- A and B for
preview.2. A closes a silent loss, the failure this package exists to prevent. B is needed by an object of11.0.0and changes the contract, which is cheapest before more contributors exist. - C before
rc.1, not forpreview.2. It changes no public answer, nothing that ships is placed before tables, and A constraint renamed in place frees its name after EF Core's operations: an index created under that name in the same migration fails with 42P07 #99 is correct as it is. It is the largest of the four and the one a preview does not need. - D with the first object SchemaKit creates on SQLite, not before. The format is permanent, and what it has to say is clearer with a real object than with the probe's index.
Three questions for the maintainer
- Is the scope on
Dependency.SchemaObjectaccepted (slice B)? Without it the order can only be kept among objects whose names are unique in the model. - Does the row guard (RowGuard: delete guards as declared triggers, with one raise-only function #47) create its trigger on SQLite in
11.0.0? If so, D is part of11.0.0and its annotation format has to be decided with RowGuard: delete guards as declared triggers, with one raise-only function #47, and A is only an interim. If not, A is the answer for11.0.0. - May C move from "before
preview.2" to the gate ofrc.1?
Before preview.2; #99 gets a point fix for preview.1. From the architecture debate of 2026-11-14; not decided. Revises the fixed order of plan section 3.6.
Problem
A plan is two lists, before and after EF Core's operations, and the name claims of #96 read the end state. So a name freed by a rename is free too late (#99), a create placed before tables can precede its schema, the order Dependency.SchemaObject promises is not kept (#24), and SQLite's rebuild at the end of a migration has no place a create can follow (plan 3.12). Every one is about a moment within the migration, which the two lists cannot say.
Change, to decide
- Ordered actions instead of two lists: each action of SchemaKit's says which names it takes and releases and what it needs to exist. EF Core's operations keep their order and are read the same way, through the effect adapters.
- A name ledger: the ordered actions are run against the source's claims. A take on a name still held turns a rename into a rebuild, or is refused when no order works. It replaces the end-state check and is the same on every provider (
sp_renameon SQL Server, one namespace per database on SQLite). - Order by
Dependency.SchemaObjectwith fully scoped identities, cycles refused. - Whether a SchemaKit statement carries what it is (kind, object, claims) as annotations on its
SqlOperation, so that the generator decorator can place it after SQLite's rebuild and a tool can explain a migration. To check first: what EF Core scaffolds of an annotation on aSqlOperation.
Done when
#99's pair and its mirror apply, a domain is created after its schema, and the ordering test of #24 holds on PostgreSQL and on the second provider.
Activity
CaffeinatedCoder commentedon Nov 16, 2026
Point 4, "to check first: what EF Core scaffolds of an annotation on a
SqlOperation": measured in spike D (#19,spikes/D.ScriptsAndBundles, 2026-11-16, EF Core11.0.0-rc.3).EF Core writes it, and the migration carries it on every path.
The annotations were put on the operations the kernel's planner built from a contributor's statement, the instances
SchemaKitModelDifferhands to EF Core (by reflection, since the kernel has no way to say it yet). They were read back by a generator standing where the provider's stands, inside SchemaKit's decorator, so it sees the list the decorator hands on.migrations add.Annotation(…)onmigrationBuilder.Sql(…), inUpand inDownmigrations script: the generator receives the operationScriptmigrations script --idempotentScript, IdempotentDefault(PostgreSQL 18)migrations addfails and writes nothingWhat
migrations addwrote for the five annotations (two strings, astring[], anintand abool), sorted by name:The refusal of a value EF Core cannot write is EF Core's own:
Cannot scaffold C# literals of type '…'. The provider should implement CoreTypeMapping.GenerateCodeLiteral to support using it at design time.What follows for the decision:
string[], anintand aboolpass; a record does not. Kind, object and claims fit as strings and string arrays.SqlOperations that are neither SchemaKit's nor the consumer's: EF Core's own for the history table (DO $EFHistory$ …on Npgsql,CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory"on SQLite).MigrationsSqlGenerationOptionsarrives with the operations. That is what An idempotent script cannot carry a statement with the transaction suppressed on PostgreSQL: the migration is recorded without its index #155 needs to refuse a statement with the transaction suppressed in an idempotent script, and the annotation is what lets it name the object.Not measured: SQLite's table rebuild itself. The generator inside the decorator receives the operations before SQLite's generator reorders them, so the annotations are there for the decorator to place a create; whether an annotated operation is then placed correctly is this issue's own work.
fix: on SQLite a create on a table the migration rebuilds is refused