No changes detected in Alembic autogeneration of migrations with Flask-SQLAlchemy

后端 未结 5 1899
有刺的猬
有刺的猬 2020-12-24 02:35

I\'m having trouble getting Alembic to autogenerate candidate migrations from changes to classes using db.Model (Flask-SQLAlchemy) instead of Base.

5条回答
  •  醉酒成梦
    2020-12-24 03:21

    I also faced this issue and using this way to solve that:

    open the migrations/env.py file, and on def run_migrations_online() function look at the context.configure, on Alembic 1.0.8 it should look 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
        )
    

提交回复
热议问题