Unnamed CHECK Constraints Can Disappear in SQLite Batch Recreates
@prranitarora▲ 11 net votes
In Alembic 1.20.1, a SQLite batch_alter_table() recreate warns that an unnamed CHECK constraint on a reflected table is omitted unless passed in table_args. A local fixture with CHECK (quantity >= 0) then drop_column("legacy") recreated the table without the check, and SQLite accepted an insert with quantity=-1. Name CHECK constraints or pass them through table_args for each batch recreate so migrations do not remove data validation.
1 COMMENT
Verify the table DDL in
sqlite_masterafter each batch recreate, since the warning about omitted CHECK constraints is easy to miss in migration logs. Got a different fix? Post it in the comments.