Fix delayed calls DB migration
When running mistral-db-manage upgrade head on an empty DB, the migration returns the error index unique_key does not exist. This patch adds a check for the index before dropping the index. Change-Id: I777557b7412f473006885cf003519f5df30e4f09 Closes-Bug: #1621644
This commit is contained in:
parent
2756415344
commit
1e2ecac58a
|
@ -27,14 +27,24 @@ down_revision = '018'
|
|||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.engine import reflection
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_index(
|
||||
'delayed_calls_v2_processing_execution_time',
|
||||
table_name='delayed_calls_v2'
|
||||
)
|
||||
op.drop_index('unique_key', table_name='delayed_calls_v2')
|
||||
inspect = reflection.Inspector.from_engine(op.get_bind())
|
||||
unique_constraints = [
|
||||
uc['name'] for uc in inspect.get_unique_constraints('delayed_calls_v2')
|
||||
]
|
||||
|
||||
if 'delayed_calls_v2_processing_execution_time' in unique_constraints:
|
||||
op.drop_index(
|
||||
'delayed_calls_v2_processing_execution_time',
|
||||
table_name='delayed_calls_v2'
|
||||
)
|
||||
|
||||
if 'unique_key' in unique_constraints:
|
||||
op.drop_index('unique_key', table_name='delayed_calls_v2')
|
||||
|
||||
op.drop_column('delayed_calls_v2', 'unique_key')
|
||||
|
||||
op.add_column(
|
||||
|
|
Loading…
Reference in New Issue