Merge "Fix db migration for mariadb >= 10.2.8"

This commit is contained in:
Zuul 2018-02-19 20:45:21 +00:00 committed by Gerrit Code Review
commit 3a11fc704c
2 changed files with 12 additions and 0 deletions

View File

@ -38,10 +38,17 @@ COLUMN_HOST = 'host'
DEFAULT_HOST = 'unknown'
COLUMN_ENTITY = 'entity_uuid'
COLUMN_KEY = 'key'
MYSQL_ENGINE = 'mysql'
def upgrade():
bind = op.get_bind()
engine = bind.engine
try:
if (engine.name == MYSQL_ENGINE):
op.drop_constraint('PRIMARY', TABLE_NAME, type_='primary')
op.create_primary_key('DRIVERS_PRIVATE_PK', TABLE_NAME,
['entity_uuid', 'key'])
op.drop_column(TABLE_NAME, COLUMN_HOST)
except Exception:
LOG.error("Column '%s' could not be dropped", COLUMN_HOST)

View File

@ -0,0 +1,5 @@
---
fixes:
- The database migration has been adjusted to work with mariadb >= 10.2.8
by ensuring that a primary key constraint is first dropped and re-added
when a column is removed that is part of it