summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Nica <snica@suse.com>2018-02-13 14:09:19 +0100
committerTom Barron <tpb@dyncloud.net>2018-02-19 21:15:54 +0000
commit4a40da15fe0e9688c363371fd998ef7c3ba321ee (patch)
tree4d2d9770451e78fa15a26eb90cd6c8604d95c59c
parent6368a9e887f5f3e51c8013c94fd92565279fb3e7 (diff)
Fix db migration for mariadb >= 10.2.86.0.0.0rc2
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 (cherry picked from commit 2beb7ac13ab640c6178a711fc39c75bd71b2bc2c)
Notes
Notes (review): Code-Review+1: Tom Barron <tpb@dyncloud.net> Code-Review+2: Ben Swartzlander <ben@swartzlander.org> Workflow+1: Ben Swartzlander <ben@swartzlander.org> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 20 Feb 2018 04:56:04 +0000 Reviewed-on: https://review.openstack.org/545981 Project: openstack/manila Branch: refs/heads/stable/queens
-rw-r--r--manila/db/migrations/alembic/versions/e8ea58723178_remove_host_from_driver_private_data.py7
-rw-r--r--releasenotes/notes/bug-1749184-eb06929e76a14fce.yaml5
2 files changed, 12 insertions, 0 deletions
diff --git a/manila/db/migrations/alembic/versions/e8ea58723178_remove_host_from_driver_private_data.py b/manila/db/migrations/alembic/versions/e8ea58723178_remove_host_from_driver_private_data.py
index 4dd885c..48f2c03 100644
--- a/manila/db/migrations/alembic/versions/e8ea58723178_remove_host_from_driver_private_data.py
+++ b/manila/db/migrations/alembic/versions/e8ea58723178_remove_host_from_driver_private_data.py
@@ -38,10 +38,17 @@ COLUMN_HOST = 'host'
38DEFAULT_HOST = 'unknown' 38DEFAULT_HOST = 'unknown'
39COLUMN_ENTITY = 'entity_uuid' 39COLUMN_ENTITY = 'entity_uuid'
40COLUMN_KEY = 'key' 40COLUMN_KEY = 'key'
41MYSQL_ENGINE = 'mysql'
41 42
42 43
43def upgrade(): 44def upgrade():
45 bind = op.get_bind()
46 engine = bind.engine
44 try: 47 try:
48 if (engine.name == MYSQL_ENGINE):
49 op.drop_constraint('PRIMARY', TABLE_NAME, type_='primary')
50 op.create_primary_key('DRIVERS_PRIVATE_PK', TABLE_NAME,
51 ['entity_uuid', 'key'])
45 op.drop_column(TABLE_NAME, COLUMN_HOST) 52 op.drop_column(TABLE_NAME, COLUMN_HOST)
46 except Exception: 53 except Exception:
47 LOG.error("Column '%s' could not be dropped", COLUMN_HOST) 54 LOG.error("Column '%s' could not be dropped", COLUMN_HOST)
diff --git a/releasenotes/notes/bug-1749184-eb06929e76a14fce.yaml b/releasenotes/notes/bug-1749184-eb06929e76a14fce.yaml
new file mode 100644
index 0000000..411bc47
--- /dev/null
+++ b/releasenotes/notes/bug-1749184-eb06929e76a14fce.yaml
@@ -0,0 +1,5 @@
1---
2fixes:
3 - The database migration has been adjusted to work with mariadb >= 10.2.8
4 by ensuring that a primary key constraint is first dropped and re-added
5 when a column is removed that is part of it