Skip to content

fix(drizzle-kit): use DROP INDEX IF EXISTS for SQLite/Turso index drops#5565

Open
muhammadosama984 wants to merge 1 commit intodrizzle-team:mainfrom
muhammadosama984:fix/sqlite-turso-drop-index-if-exists-5564
Open

fix(drizzle-kit): use DROP INDEX IF EXISTS for SQLite/Turso index drops#5565
muhammadosama984 wants to merge 1 commit intodrizzle-team:mainfrom
muhammadosama984:fix/sqlite-turso-drop-index-if-exists-5564

Conversation

@muhammadosama984
Copy link
Copy Markdown

Summary

  • make LibSQLModifyColumn emit DROP INDEX IF EXISTS when dropping indexes during Turso/libSQL alter-column/check-constraint flows
  • make SqliteDropIndexConvertor emit DROP INDEX IF EXISTS for explicit SQLite/Turso drop_index statements
  • update affected SQLite/libSQL push + statement tests and add regression coverage for multi-table alter-column flows to assert idempotent index-drop SQL

Root Cause

LibSQLModifyColumn.convert() can run multiple times in a single drizzle-kit push execution. It currently emits bare DROP INDEX statements; repeated drops on the same index then fail with no such index in SQLite/libSQL.

SqliteDropIndexConvertor.convert() also emits bare DROP INDEX, which is non-idempotent.

Fix

Use DROP INDEX IF EXISTS in both paths so repeated drops become no-ops.

Validation

  • pnpm --filter drizzle-kit exec vitest tests/libsql-statements.test.ts tests/push/libsql.test.ts tests/push/sqlite.test.ts --run

Closes #5564

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: [SQLite/Turso] LibSQLModifyColumn generates duplicate DROP INDEX (without IF EXISTS) causing "no such index" on db:push

1 participant