Skip to content

fix: on SQLite a create on a table the migration rebuilds is refused - #194

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
fix/145-sqlite-rebuild-refusal
Nov 25, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
fix/145-sqlite-rebuild-refusal

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #145
Closes #193

Slice A of #115 (decided 2026-11-25).

Problem

On SQLite the provider writes most changes of a table as a rebuild, and its generator moves the rebuild to the end of the migration. A create the planner writes for an object on that table runs first, on the old table:

A fourth silent case, #193: when the operation that makes the rebuild stands before the table's rename, the planner did not connect the rebuild with the objects on the table and wrote nothing.

Neither package creates objects on SQLite; a contributor written against the contract reaches this.

Change

  • A create of an object on a table the same migration rebuilds is refused where the migration is scaffolded, with the declaration and the table named. An object is on a table when it reads a column of it or holds SQL written by hand, which is how the planner ties an object to a table everywhere else.
  • The refusal names the way round it, and that way is measured: the declaration taken out, the table changed, the declaration put back, a migration each (In_three_migrations_the_table_is_changed_and_the_index_is_there).
  • The seven tests of SqliteExpressionIndexTests that held today's outcomes, four failures at apply and three silent losses, hold the refusal and that the database is not touched. The kernel's On_sqlite_an_index_lost_to_a_rebuild_is_refused_at_the_diff holds the same, and that the same two models on Npgsql are one AlterColumnOperation and no refusal.
  • Only creates are refused. An object whose contributor answers that the rebuild leaves it alone is the contributor's word (Answered_as_unaffected_the_rebuild_takes_the_index_without_a_word, unchanged).

Found on the way: #193, a fourth way into the same loss, fixed on this branch. A rebuild whose operation stands before the table's rename named the table as it was, the planner did not connect it with the objects on the table, wrote nothing, and the migration applied without the index.

The first form of the refusal had three parts no test held. Two were redundant and are gone: the check that the provider is SQLite, since only SQLite's operations are read as rebuilds, and an object's scope as a tie to its table. The third was the rule #193 is about.

Tests

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

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

Changed Fails
No refusal the kernel's test and eight of the second provider's
A rebuild names its table as its operation does (#193) A_rebuild_written_for_the_table_under_its_old_name_is_refused_too
A column an object reads does not tie it to the table the kernel's test and eight of the second provider's
Hand-written SQL does not tie an object to the table An_index_of_hand_written_sql_on_the_rebuilt_table_is_refused, added after the run showed nothing held it

🤖 Generated with Claude Code

SQLite's generator moves a table rebuild to the end of the migration,
behind every statement written after the operation it stands for. A
create on such a table ran on the old table: it met the object that was
still there and failed at apply, or, under a name that was free, it
succeeded and the rebuild dropped the object with the old table. The
migration applied and the database lacked what the model declares.

The diff is refused, with the declaration and the table named and the
way round it: the declaration taken out, the table changed, the
declaration put back, a migration each. The refusal goes when the
generator places the create behind the rebuild (#115).

A TableRebuilt names its table as the target has it. Its operation may
stand before the table's rename and name it as the source has it; taken
as written, the objects on a table renamed and rebuilt in one migration
did not hear of the rebuild and were lost without a word (#193).

Closes #145
Closes #193

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 bug Something isn't working silent Answers wrongly without throwing; the fix ships as a minor, never a patch package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) severity/medium Inconsistency or failure in a narrow scenario area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring labels Nov 25, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 0693fa6 into main Nov 25, 2026
11 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/145-sqlite-rebuild-refusal branch November 25, 2026 13:39
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 bug Something isn't working package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) severity/medium Inconsistency or failure in a narrow scenario silent Answers wrongly without throwing; the fix ships as a minor, never a patch

Projects

None yet

1 participant