weixin_39890652 2020-11-30 11:37
浏览 0

create_unique_constraint not working with naming conventions

Migrated issue, originally created by Matt Jernigan ()

v0.8.4

autogenerate creates this:


op.create_unique_constraint('form_name', 'forms', ['org_code', 'form_name'])
op.drop_constraint('uq_forms_form_name', 'forms', type_='unique')

instead of this:


op.drop_constraint('uq_forms_form_name', 'forms', type_='unique')
op.create_unique_constraint(op.f('uq_forms_form_name'), 'forms', ['org_code', 'form_name'])

Several problems here:

  1. Order: drop should be before create.
  2. Create should maybe use op.f()
  3. And, most notably, op.create_unique_constraint('form_name', ...) does not apply naming conventions (it creates a unique constraint called form_name in this case).

该提问来源于开源项目:sqlalchemy/alembic

  • 写回答

10条回答 默认 最新

  • weixin_39890652 2020-11-30 11:37
    关注

    Michael Bayer () wrote:

    Hi there -

    Unfortunately I have no idea what you are trying to do or how you are trying to do it. Alembic autogenerate does not detect changes in constraint names if that's what you're trying to do. Please provide minimal examples of the models in use both before and after the autogenerate operation.

    评论

报告相同问题?