Set InnoDB engine for all existing tables
Added the method in heal script that checks if mysql_engine parameter is needed to be changed and if it is neseccary do this. Also this change adds migation that set 'mysql_engine' to InnoDB for all tables that were added into the database after healing. Closes-bug: #1346966 Change-Id: Ia4d9038b99b2559d37272a17f5819a9dedd53f72
This commit is contained in:
parent
be15088b94
commit
2b4f627079
@ -69,7 +69,7 @@ def heal():
|
||||
'compare_server_default': _compare_server_default,
|
||||
}
|
||||
mc = alembic.migration.MigrationContext.configure(op.get_bind(), opts=opts)
|
||||
|
||||
set_storage_engine(op.get_bind(), "InnoDB")
|
||||
diff1 = autogen.compare_metadata(mc, models_metadata)
|
||||
# Alembic does not contain checks for foreign keys. Because of that it
|
||||
# checks separately.
|
||||
@ -320,3 +320,11 @@ def _compare_server_default(ctxt, ins_col, meta_col, insp_def, meta_def,
|
||||
)
|
||||
|
||||
return None # tells alembic to use the default comparison method
|
||||
|
||||
|
||||
def set_storage_engine(bind, engine):
|
||||
insp = sqlalchemy.engine.reflection.Inspector.from_engine(bind)
|
||||
if bind.dialect.name == 'mysql':
|
||||
for table in insp.get_table_names():
|
||||
if insp.get_table_options(table)['mysql_engine'] != engine:
|
||||
op.execute("ALTER TABLE %s ENGINE=%s" % (table, engine))
|
||||
|
@ -0,0 +1,46 @@
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
"""set_innodb_engine
|
||||
|
||||
Revision ID: 327ee5fde2c7
|
||||
Revises: 2026156eab2f
|
||||
Create Date: 2014-07-24 12:00:38.791287
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '327ee5fde2c7'
|
||||
down_revision = '4eba2f05c2f4'
|
||||
|
||||
|
||||
from alembic import op
|
||||
|
||||
# This list contain tables that could be deployed before change that converts
|
||||
# all tables to InnoDB appeared
|
||||
TABLES = ['router_extra_attributes', 'dvr_host_macs', 'ml2_dvr_port_bindings',
|
||||
'csnat_l3_agent_bindings']
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
|
||||
if op.get_bind().dialect.name == 'mysql':
|
||||
for table in TABLES:
|
||||
op.execute("ALTER TABLE %s ENGINE=InnoDB" % table)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
|
||||
pass
|
@ -1 +1 @@
|
||||
4eba2f05c2f4
|
||||
327ee5fde2c7
|
||||
|
Loading…
Reference in New Issue
Block a user