Skip to content

SQLite: re-create complex indexes after a table rebuild instead of refusing the migration #95

Closed

Description

@CaffeinatedCoder

Goal

#86 makes migrations add refuse, on SQLite, a migration whose table rebuild would drop a complex index, and points the consumer to a three-migration split. That is honest but costly: a table rename or an ALTER COLUMN on a table with a complex index now takes three migrations.

The real fix needs a step after EF Core's rewrite: SqliteMigrationsSqlGenerator.RewriteOperations emits every rebuild after all other operations, so nothing the differ emits can run after it.

Proposal

  • UseComplexIndexes() on SQLite also wraps the provider's IMigrationsSqlGenerator: it generates the inner commands, then appends the CREATE INDEX of every complex index on each rebuilt table.
  • The differ marks those creates (an annotation) and ANDs a call to __requires_UseComplexIndexes__() onto their filter, so a missing registration fails loudly at apply time instead of losing the index. Not the column sentinel: SQLite with double-quoted string literals on accepts an unknown quoted column as a string. With the wrapper in effect, which the differ asks the context for, the refusal of SQLite: a migration that rebuilds a table silently drops every complex index on it #86 is lifted.
  • Design questions: decorating a provider service EF registers by type; the design-time path (dotnet ef database update uses the context's runtime services, so the registration must be in the context); idempotent scripts.

Ships in 5.5.0 (epic #36), as a changed answer: the refusal becomes a migration. Design and measurements: #138.

Activity

  1. added this to the 5.6.0 milestone on Oct 19, 2026
  2. added
    enhancement
    package/core
    area/indexes
    area/migrations
    on Oct 19, 2026
  3. modified the milestones: 5.6.0, 5.5.0 on Oct 20, 2026
  4. added a commit that references this issue on Oct 20, 2026
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/indexesarea/migrationsenhancementpackage/core

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions