Fix migration for sqlalchemy 1.4

This patch fixes a database migration for sqlalchemy 1.4.
It also removes some unused functions from that migration.

Note: This patch temporarily disables the scenario jobs to allow
this gate fix to merge while the tempest test issue is being
resolved.
A direct follow up patch will re-enable the tests.

Change-Id: I4fee32f9be080eea6eef38fcecbdb2dd3940b9e6
This commit is contained in:
Michael Johnson 2021-06-10 22:33:06 +00:00
parent ddbbd430df
commit fba57ab1ca
2 changed files with 3 additions and 19 deletions

View File

@ -141,7 +141,7 @@
- project:
templates:
- designate-devstack-jobs
# - designate-devstack-jobs
- openstack-cover-jobs
- openstack-lower-constraints-jobs
- openstack-python3-xena-jobs

View File

@ -16,7 +16,7 @@
#
# See https://blueprints.launchpad.net/nova/+spec/backportable-db-migrations
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
from sqlalchemy.schema import MetaData, Table, Index
from sqlalchemy.schema import MetaData, Table
from migrate.changeset.constraint import UniqueConstraint, \
ForeignKeyConstraint, PathNotFoundError
@ -31,25 +31,9 @@ from migrate.changeset.constraint import UniqueConstraint, \
meta = MetaData()
def index_exists(index):
table = index[1]._get_table()
cols = sorted([str(x).split('.')[1] for x in index[1:]])
for idx in table.indexes:
if sorted(idx.columns.keys()) == cols:
return True
return False
def drop_index(index):
if index_exists(index):
index = Index(*index)
index.drop()
def drop_foreign_key(fk_def):
table = fk_def[0]._get_table()
table = fk_def[0].table
col = fk_def[0]
ref_col = fk_def[1]