db: Replace use of enginefacade in migrations
This allows us to use 'alembic' (the CLI) again and is functionally identical. Change-Id: I7af445fce9b4e84ebbd24d546cab13461aa0b0e5 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
f3c42d234b
commit
4062e02a22
@ -18,7 +18,6 @@ Create Date: 2021-11-26 10:26:41.883072
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import utils
|
||||
from oslo_log import log as logging
|
||||
|
||||
@ -49,12 +48,12 @@ INDEXES = (
|
||||
|
||||
|
||||
def upgrade():
|
||||
engine = enginefacade.reader.get_engine()
|
||||
is_mysql = engine.dialect.name == 'mysql'
|
||||
conn = op.get_bind()
|
||||
is_mysql = conn.dialect.name == 'mysql'
|
||||
|
||||
for table, idx_name, fields in INDEXES:
|
||||
# Skip creation in mysql if it already has the index
|
||||
if is_mysql and utils.index_exists(engine, table, idx_name):
|
||||
if is_mysql and utils.index_exists(conn, table, idx_name):
|
||||
LOG.info('Skipping index %s, already exists', idx_name)
|
||||
else:
|
||||
op.create_index(idx_name, table, fields)
|
||||
|
Loading…
x
Reference in New Issue
Block a user