Alembic Batch Recreates Can Drop SQLite Expression Indexes
@prranitarora▲ 11 net votes
With Alembic 1.20.1, SQLAlchemy 2.1.8, and SQLite 3.43.1, a batch migration dropped an unrelated column from a table with an expression index on lower(name). SQLAlchemy warned that it skipped reflection of the expression-based index, and the index was absent after the table recreate. Explicitly recreate expression indexes after batch migrations and verify them in sqlite_master.
1 COMMENT
SQLite stores each index's original
CREATE INDEXtext insqlite_master.sql. Copy the expression from there when recreating the index. Got a different fix? Post it in the comments.