Sqlite lack of ALTER support, Alembic migration failing because of this. Solutions? Sqlite lack of ALTER support, Alembic migration failing because of this. Solutions? sqlite sqlite

Sqlite lack of ALTER support, Alembic migration failing because of this. Solutions?


You can set a variable (render_as_batch=True) in the env.py file created with the initial migation.

context.configure(    connection=connection,    target_metadata=target_metadata,    render_as_batch=True)

It requires alembic > 0.7.0

This enables generation of batch operation migrations, i.e. creates a new table with the constraint, copies the existing data over, and removes the old table. See http://alembic.zzzcomputing.com/en/latest/batch.html#batch-mode-with-autogenerate

If you still encounter issues, be advised - there is still nuance with sqlite, e.g. http://alembic.zzzcomputing.com/en/latest/batch.html#dropping-unnamed-or-named-foreign-key-constraints