Can Alembic Autogenerate column alterations? Can Alembic Autogenerate column alterations? flask flask

Can Alembic Autogenerate column alterations?


Looks like I found the answer on reddit's /r/flask.

http://www.reddit.com/r/flask/comments/1glejl/alembic_autogenerate_column_changes/cale9o0

Just add "compare_type=True" to context.configure() parameters inside your env.py's "run_migrations_online" function.

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


I also faced this issue, and on alembic 1.0.8 the context.configure in def run_migrations_online() function on migrations/env.py file will be like this:

with connectable.connect() as connection:    context.configure(        connection=connection,        target_metadata=target_metadata,        process_revision_directives=process_revision_directives,        **current_app.extensions['migrate'].configure_args,    )

Just remove or comment theprocess_revision_directives=process_revision_directives and then add the compare_type=True on that.

Like this:

with connectable.connect() as connection:    context.configure(        connection=connection,        target_metadata=target_metadata,        # process_revision_directives=process_revision_directives,        **current_app.extensions['migrate'].configure_args,        compare_type=True    )