Fix db migration for mariadb >= 10.2.8
Starting with mariadb 10.2.8, removing a column that is part of a primary key requires that the primary key constraint be dropped and recreated. Change-Id: I43e4dae325dd6561a9fe0fd4ce595cea4c2ef7a6 Closes-Bug: #1749184
This commit is contained in:
parent
6368a9e887
commit
2beb7ac13a
@ -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)
|
||||
|
5
releasenotes/notes/bug-1749184-eb06929e76a14fce.yaml
Normal file
5
releasenotes/notes/bug-1749184-eb06929e76a14fce.yaml
Normal 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
|
Loading…
Reference in New Issue
Block a user