Skip to content

On SQLite a rebuild written under the table's old name is not seen: an object on a table that is renamed and rebuilt is lost in silence #193

Done

Description

@CaffeinatedCoder

Found while building the refusal of #145, on main @ c6dfd42 (EF Core 11.0.0), with the second provider's SQLite probe.

What happens

A check constraint is dropped from People, the table becomes Persons, and its primary key keeps its name. EF Core writes DropCheckConstraintOperation (for People) and then RenameTableOperation. SQLite's provider rebuilds the table for the first. The planner adds nothing:

DropCheckConstraintOperation | RenameTableOperation

The contributor is never asked about the rebuild, so the index both models declare is not created again, and the rebuild drops it with the old table. The migration applies and the snapshot still holds the declaration.

Why

BaseChanges.Touching compares a change's table with the object's tables as the target names them (Forward). A TableRebuilt carries the table as its operation names it, and an operation that stands before the rename names it as the source has it: People is compared with Persons. The operations EF Core writes before a rename are the drops of keys and constraints, each of which SQLite rebuilds for.

A fourth way into #145, and not covered by its refusal: nothing is created, so nothing is refused.

Scenario

People.IndexedWithANamedKeyAndACheck to People.TableRenamedWithANamedKey in SqliteExpressionIndexTests.

Change

A TableRebuilt names its table as the target has it, as the other changes do, whichever side of the rename its operation stands on.

Test

A_rebuild_written_for_the_table_under_its_old_name_is_refused_too: with the fix the object is to be created again, and #145's refusal says so at the diff.

Activity

  1. added this to the 11.0.0 milestone on Nov 25, 2026
  2. added
    bug
    silent
    package/core
    severity/medium
    area/migrations
    on Nov 25, 2026
  3. CaffeinatedCoder commented on Nov 25, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Fixed on fix/145-sqlite-rebuild-refusal with #145: BaseChanges.Of names a TableRebuilt's table as the target has it. A_rebuild_written_for_the_table_under_its_old_name_is_refused_too fails with the fix taken out (the planner writes nothing and nothing is refused) and passes with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/migrationsbugpackage/coreseverity/mediumsilent

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions