Merge "Fix drop index in version 022 DB upgrade script"

This commit is contained in:
Jenkins 2017-08-03 09:27:14 +00:00 committed by Gerrit Code Review
commit 75ed360270

View File

@ -27,8 +27,10 @@ down_revision = '021'
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy.engine import reflection
from sqlalchemy.sql import table, column from sqlalchemy.sql import table, column
# A simple model of the workflow definitions table with only the field needed # A simple model of the workflow definitions table with only the field needed
wf_def = table('workflow_definitions_v2', column('namespace')) wf_def = table('workflow_definitions_v2', column('namespace'))
@ -60,7 +62,16 @@ def upgrade():
) )
) )
op.drop_index('name', table_name='workflow_definitions_v2') inspect = reflection.Inspector.from_engine(op.get_bind())
unique_constraints = [
unique_constraint['name'] for unique_constraint in
inspect.get_unique_constraints('workflow_definitions_v2')
]
if 'name' in unique_constraints:
op.drop_index('name', table_name='workflow_definitions_v2')
op.create_unique_constraint( op.create_unique_constraint(
None, None,
'workflow_definitions_v2', 'workflow_definitions_v2',