db: Compact Stein database migrations

Compact Stein database migrations into a single migration,
'390_stein.py'.

Users will now need to update to Stein before updating to Train or
later.

Specific changes include:

- Add 'volume_type' column to 'block_device_mapping' table (391)

Note that this change is unusual in that there are no placeholder
migrations to clean up from the previous release. This is because we
forgot to include them during the Rocky release.

When testing, the previous base version was 390. It is now 391.

Change-Id: Id77311b7b46b8230c0ce23f8eeb8d4dca7b38e88
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2020-10-21 11:44:07 +01:00
parent 02d6a96588
commit f0175a346a
4 changed files with 2 additions and 41 deletions

View File

@ -1,32 +0,0 @@
# 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.
from sqlalchemy import Column
from sqlalchemy import MetaData
from sqlalchemy import String
from sqlalchemy import Table
BASE_TABLE_NAME = 'block_device_mapping'
NEW_COLUMN_NAME = 'volume_type'
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
for prefix in ('', 'shadow_'):
table = Table(prefix + BASE_TABLE_NAME, meta, autoload=True)
new_column = Column(NEW_COLUMN_NAME, String(255), nullable=True)
if not hasattr(table.c, NEW_COLUMN_NAME):
table.create_column(new_column)

View File

@ -236,6 +236,7 @@ def upgrade(migrate_engine):
Column('tag', String(255)),
Column('attachment_id', String(36), nullable=True),
Column('uuid', String(36), nullable=True),
Column('volume_type', String(255), nullable=True),
UniqueConstraint('uuid', name='uniq_block_device_mapping0uuid'),
mysql_engine='InnoDB',
mysql_charset='utf8'

View File

@ -29,7 +29,7 @@ from nova import exception
from nova.i18n import _
INIT_VERSION = {}
INIT_VERSION['main'] = 389
INIT_VERSION['main'] = 390
INIT_VERSION['api'] = 0
_REPOSITORY = {}

View File

@ -162,9 +162,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
self.INIT_VERSION + 1,
]
# We forgot to add the rocky placeholder. We've also switched to 5
# placeholders per cycle since the rate of DB changes has dropped
# significantly
stein_placeholders = list(range(392, 397))
train_placeholders = list(range(403, 408))
ussuri_placeholders = list(range(408, 413))
@ -229,11 +226,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
def test_walk_versions(self):
self.walk_versions(snake_walk=False, downgrade=False)
def _check_391(self, engine, data):
self.assertColumnExists(engine, 'block_device_mapping', 'volume_type')
self.assertColumnExists(engine, 'shadow_block_device_mapping',
'volume_type')
def _check_397(self, engine, data):
for prefix in ('', 'shadow_'):
self.assertColumnExists(