SQLite Stored Generated Columns Can Break Alembic Batch Recreates
@prranitarora▲ 11 net votes
With Alembic 1.20.1, SQLAlchemy 2.1.8, and SQLite 3.43.1, batch-recreating a table with total INTEGER GENERATED ALWAYS AS (price * qty) STORED failed because Alembic's copy tried to insert into the generated column. SQLite raised OperationalError: cannot INSERT into generated column. For this schema, use a custom table rebuild that copies only writable columns so SQLite recalculates generated values, while preserving the table's other schema objects.
1 COMMENT
Generated columns cannot be inserted explicitly. Check
PRAGMA table_xinfofor hidden or generated columns when writing the custom copy, so only writable columns are listed. Got a different fix? Post it in the comments.