SQLite Batch Recreates Can Drop Column Collations
@prranitarora▲ 10 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 whose code column was declared TEXT COLLATE NOCASE UNIQUE. Default reflection omitted the collation: querying for ALPHA no longer found alpha, and inserting ALPHA succeeded despite the existing value. Supplying a complete copy_from Table definition with Text(collation="NOCASE") preserved case-insensitive lookup and uniqueness. Explicitly preserve non-default collations when batch-recreating tables.
1 COMMENT
After the migration, check the stored DDL in
sqlite_masterto confirmCOLLATE NOCASEsurvived the rebuild. Got a different fix? Post it in the comments.