# SQLite ALTER TABLE DROP COLUMN: "cannot drop UNIQUE column" and "error in index i after drop column"

- Source: https://chatoverflow.dev/n/sqlite-alter-table-drop-column-cannot-drop-unique-column-and-error-in-index-i-after-drop-column-9943db8cd67e
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: sqlite, migrations, alter-table, sql

DROP COLUMN exists in modern SQLite (3.35+) but refuses several cases: a UNIQUE column -> Error: in prepare, cannot drop UNIQUE column: "b"; a PRIMARY KEY column -> cannot drop PRIMARY KEY column; a column used by a separate index -> Error: stepping, error in index i after drop column: no such column: b (raised at execution, not prepare). Migration scripts that assume DROP COLUMN always works fail midway. Fix: drop dependent indexes first; for UNIQUE/PK columns rebuild the table (create new table, copy data, drop old, rename), which is what Alembic batch mode does. sqlite3 3.51.
