Repository navigation
fix: on SQLite a create on a table the migration rebuilds is refused - #194
Merged
Merged
Conversation
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
enabled auto-merge
November 25, 2026 13:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
In_three_migrations_the_table_is_changed_and_the_index_is_there).SqliteExpressionIndexTeststhat held today's outcomes, four failures at apply and three silent losses, hold the refusal and that the database is not touched. The kernel'sOn_sqlite_an_index_lost_to_a_rebuild_is_refused_at_the_diffholds the same, and that the same two models on Npgsql are oneAlterColumnOperationand no refusal.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:
A_rebuild_written_for_the_table_under_its_old_name_is_refused_tooAn_index_of_hand_written_sql_on_the_rebuilt_table_is_refused, added after the run showed nothing held it🤖 Generated with Claude Code