From 171ff11e905a2103443c547d28f84f98a651491c Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 17 Feb 2023 12:42:53 +0000 Subject: [PATCH] db: Remove the legacy 'migration_version' table This hasn't been necessary since Xena. Change-Id: Ia1b92341fc44fa903c238b2cb82496b77012a367 Signed-off-by: Stephen Finucane --- ...639f9_drop_legacy_migrate_version_table.py | 35 +++++++++++++++++++ .../daa98075b90d_add_resource_indexes.py | 2 +- cinder/tests/unit/db/test_migrations.py | 14 +++----- 3 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 cinder/db/migrations/versions/89aa6f9639f9_drop_legacy_migrate_version_table.py diff --git a/cinder/db/migrations/versions/89aa6f9639f9_drop_legacy_migrate_version_table.py b/cinder/db/migrations/versions/89aa6f9639f9_drop_legacy_migrate_version_table.py new file mode 100644 index 00000000000..d0f49cf1c15 --- /dev/null +++ b/cinder/db/migrations/versions/89aa6f9639f9_drop_legacy_migrate_version_table.py @@ -0,0 +1,35 @@ +# 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. + +"""Drop legacy migrate_version table + +Revision ID: 89aa6f9639f9 +Revises: daa98075b90d +Create Date: 2023-02-17 12:41:37.940769 +""" + +from alembic import op +from sqlalchemy.engine import reflection + +# revision identifiers, used by Alembic. +revision = '89aa6f9639f9' +down_revision = 'daa98075b90d' +branch_labels = None +depends_on = None + + +def upgrade(): + conn = op.get_bind() + inspector = reflection.Inspector.from_engine(conn) + tables = inspector.get_table_names() + if 'migrate_version' in tables: + op.drop_table('migrate_version') diff --git a/cinder/db/migrations/versions/daa98075b90d_add_resource_indexes.py b/cinder/db/migrations/versions/daa98075b90d_add_resource_indexes.py index b1135c6a722..345c4643e5d 100644 --- a/cinder/db/migrations/versions/daa98075b90d_add_resource_indexes.py +++ b/cinder/db/migrations/versions/daa98075b90d_add_resource_indexes.py @@ -13,7 +13,7 @@ """Add resource indexes Revision ID: daa98075b90d -Revises: 9c74c1c6971f +Revises: c92a3e68beed Create Date: 2021-11-26 10:26:41.883072 """ diff --git a/cinder/tests/unit/db/test_migrations.py b/cinder/tests/unit/db/test_migrations.py index 23fe49e7644..2d3abff2316 100644 --- a/cinder/tests/unit/db/test_migrations.py +++ b/cinder/tests/unit/db/test_migrations.py @@ -62,15 +62,6 @@ class CinderModelsMigrationsSync(test_migrations.ModelsMigrationsSync): def get_metadata(self): return models.BASE.metadata - def include_object(self, object_, name, type_, reflected, compare_to): - if type_ == 'table': - # migrate_version is a sqlalchemy-migrate control table and - # isn't included in the model - if name == 'migrate_version': - return False - - return True - def filter_metadata_diff(self, diff): # Overriding the parent method to decide on certain attributes # that maybe present in the DB but not in the models.py @@ -219,6 +210,11 @@ class MigrationsWalk( db_utils.index_exists(connection, 'volumes', 'volumes_deleted_host_idx') + def _check_89aa6f9639f9(self, connection): + # the table only existed on legacy deployments: there's no way to check + # for its removal without creating it first, which is dumb + pass + class TestMigrationsWalkSQLite( MigrationsWalk,