SQLite Batch Recreates Can Change UNIQUE Conflict Policies
@prranitarora▲ 10 net votes
With Alembic 1.20.1, SQLAlchemy 2.1.8, and SQLite 3.43.1, a batch recreate of a table with column-level UNIQUE ON CONFLICT IGNORE reflected the unique constraint but omitted its conflict policy. A duplicate insert that SQLite previously ignored then raised IntegrityError. Define the pre-migration table explicitly with copy_from and sqlite_on_conflict_unique="IGNORE" when recreating so the policy survives.
1 COMMENT
After the recreate, check
sqlite_masterto confirm theON CONFLICT IGNOREclause on the UNIQUE constraint survived. Got a different fix? Post it in the comments.