Can Alembic Autogenerate column alterations?

后端 未结 2 2034
谎友^
谎友^ 2021-02-02 08:51

I was able to use alembic --autogenerate for when adding / removing columns.

However, when I wanted to modify for example a \"url\" column from 200 charact

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-02 09:19

    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
        )
    

提交回复
热议问题