From 38f2ad54b343152f0edba817b191d456d4303d17 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Mon, 19 Sep 2016 15:37:44 -0500 Subject: [PATCH] Compact Liberty database migrations This compacts all database migrations up to Liberty into one initial schema to remove the need to apply every database change along the way. Change-Id: Id3b43e0df3162e368007c705d249539047d5da08 --- cinder/db/migration.py | 2 +- .../versions/047_add_per_volume_quota.py | 44 ------------------- .../versions/048_add_allocated_in_quotas.py | 25 ----------- ...add_temp_volume_snapshot_ids_to_backups.py | 31 ------------- .../050_add_previous_status_to_volumes.py | 27 ------------ ...source_cgid_column_to_consistencygroups.py | 26 ----------- ...2_add_provider_auth_column_to_snapshots.py | 25 ----------- .../053_add_version_columns_to_service.py | 36 --------------- ...has_dependent_backups_column_to_backups.py | 33 -------------- .../055_add_image_volume_cache_table.py | 37 ---------------- .../migrate_repo/versions/056_placeholder.py | 19 -------- .../migrate_repo/versions/057_placeholder.py | 19 -------- .../migrate_repo/versions/058_placeholder.py | 19 -------- .../migrate_repo/versions/059_placeholder.py | 19 -------- .../migrate_repo/versions/060_placeholder.py | 19 -------- ...61_add_snapshot_id_timestamp_to_backups.py | 30 ------------- ...{046_cinder_init.py => 061_cinder_init.py} | 37 +++++++++++++++- ...-schema-from-liberty-f5fa57d67441dece.yaml | 6 +++ 18 files changed, 42 insertions(+), 412 deletions(-) delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/047_add_per_volume_quota.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/048_add_allocated_in_quotas.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/049_add_temp_volume_snapshot_ids_to_backups.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/050_add_previous_status_to_volumes.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/051_add_source_cgid_column_to_consistencygroups.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/052_add_provider_auth_column_to_snapshots.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/053_add_version_columns_to_service.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/054_add_has_dependent_backups_column_to_backups.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/055_add_image_volume_cache_table.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/056_placeholder.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/057_placeholder.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/058_placeholder.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/059_placeholder.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/060_placeholder.py delete mode 100644 cinder/db/sqlalchemy/migrate_repo/versions/061_add_snapshot_id_timestamp_to_backups.py rename cinder/db/sqlalchemy/migrate_repo/versions/{046_cinder_init.py => 061_cinder_init.py} (93%) create mode 100644 releasenotes/notes/db-schema-from-liberty-f5fa57d67441dece.yaml diff --git a/cinder/db/migration.py b/cinder/db/migration.py index 38008499df3..ba5bc3a76ec 100644 --- a/cinder/db/migration.py +++ b/cinder/db/migration.py @@ -28,7 +28,7 @@ from cinder import exception from cinder.i18n import _ -INIT_VERSION = 45 +INIT_VERSION = 60 _IMPL = None _LOCK = threading.Lock() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/047_add_per_volume_quota.py b/cinder/db/sqlalchemy/migrate_repo/versions/047_add_per_volume_quota.py deleted file mode 100644 index 5e9f7d2cdb7..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/047_add_per_volume_quota.py +++ /dev/null @@ -1,44 +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 oslo_utils import timeutils -from sqlalchemy import MetaData, Table - - -# Get default value via config. The default will either -# come from the default value set in the quota configuration option -# or via cinder.conf if the user has configured -# default value for per volume size limit there. - - -def upgrade(migrate_engine): - """Add default "per_volume_gigabytes" row into DB.""" - meta = MetaData() - meta.bind = migrate_engine - quota_classes = Table('quota_classes', meta, autoload=True) - row = quota_classes.count().\ - where(quota_classes.c.resource == 'per_volume_gigabytes').\ - execute().scalar() - - # Do not add entry if there is already 'default' entry exists - # in the database. - # We don't want to write over something the user added. - if row: - return - - # Set default per_volume_gigabytes for per volume size - qci = quota_classes.insert() - qci.execute({'created_at': timeutils.utcnow(), - 'class_name': 'default', - 'resource': 'per_volume_gigabytes', - 'hard_limit': -1, - 'deleted': False, }) diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/048_add_allocated_in_quotas.py b/cinder/db/sqlalchemy/migrate_repo/versions/048_add_allocated_in_quotas.py deleted file mode 100644 index b626a08bfde..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/048_add_allocated_in_quotas.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2015 Yahoo Inc. -# -# 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, Integer, MetaData, Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - quotas = Table('quotas', meta, autoload=True) - - # Add a new column allocated to save allocated quota - allocated = Column('allocated', Integer, default=0) - quotas.create_column(allocated) diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/049_add_temp_volume_snapshot_ids_to_backups.py b/cinder/db/sqlalchemy/migrate_repo/versions/049_add_temp_volume_snapshot_ids_to_backups.py deleted file mode 100644 index 037a7b1412a..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/049_add_temp_volume_snapshot_ids_to_backups.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2015 EMC Corporation -# All Rights Reserved. -# -# 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, MetaData, String, Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - backups = Table('backups', meta, autoload=True) - temp_volume_id = Column('temp_volume_id', String(length=36)) - temp_snapshot_id = Column('temp_snapshot_id', String(length=36)) - - backups.create_column(temp_volume_id) - backups.update().values(temp_volume_id=None).execute() - - backups.create_column(temp_snapshot_id) - backups.update().values(temp_snapshot_id=None).execute() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/050_add_previous_status_to_volumes.py b/cinder/db/sqlalchemy/migrate_repo/versions/050_add_previous_status_to_volumes.py deleted file mode 100644 index 654fdce7ccf..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/050_add_previous_status_to_volumes.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2015 EMC Corporation -# All Rights Reserved. -# -# 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, MetaData, String, Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - volumes = Table('volumes', meta, autoload=True) - previous_status = Column('previous_status', String(length=255)) - - volumes.create_column(previous_status) - volumes.update().values(previous_status=None).execute() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/051_add_source_cgid_column_to_consistencygroups.py b/cinder/db/sqlalchemy/migrate_repo/versions/051_add_source_cgid_column_to_consistencygroups.py deleted file mode 100644 index 01b9ee77430..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/051_add_source_cgid_column_to_consistencygroups.py +++ /dev/null @@ -1,26 +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, String, Table - - -def upgrade(migrate_engine): - """Add source_cgid column to consistencygroups.""" - meta = MetaData() - meta.bind = migrate_engine - - consistencygroups = Table('consistencygroups', meta, autoload=True) - source_cgid = Column('source_cgid', String(36)) - - consistencygroups.create_column(source_cgid) - consistencygroups.update().values(source_cgid=None).execute() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/052_add_provider_auth_column_to_snapshots.py b/cinder/db/sqlalchemy/migrate_repo/versions/052_add_provider_auth_column_to_snapshots.py deleted file mode 100644 index d618f88f83f..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/052_add_provider_auth_column_to_snapshots.py +++ /dev/null @@ -1,25 +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, String, Table - - -def upgrade(migrate_engine): - """Add provider_auth column to snapshots.""" - meta = MetaData() - meta.bind = migrate_engine - - snapshots = Table('snapshots', meta, autoload=True) - provider_auth = Column('provider_auth', String(255)) - snapshots.create_column(provider_auth) - snapshots.update().values(provider_auth=None).execute() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/053_add_version_columns_to_service.py b/cinder/db/sqlalchemy/migrate_repo/versions/053_add_version_columns_to_service.py deleted file mode 100644 index 25ead6561fe..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/053_add_version_columns_to_service.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2015 SimpliVity Corp. -# All Rights Reserved. -# -# 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, String, Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - services = Table('services', meta, autoload=True) - rpc_current_version = Column('rpc_current_version', String(36)) - rpc_available_version = Column('rpc_available_version', String(36)) - object_current_version = Column('object_current_version', String(36)) - object_available_version = Column('object_available_version', String(36)) - services.create_column(rpc_current_version) - services.create_column(rpc_available_version) - services.create_column(object_current_version) - services.create_column(object_available_version) - services.update().values(rpc_current_version=None).execute() - services.update().values(rpc_available_version=None).execute() - services.update().values(object_current_version=None).execute() - services.update().values(object_available_version=None).execute() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/054_add_has_dependent_backups_column_to_backups.py b/cinder/db/sqlalchemy/migrate_repo/versions/054_add_has_dependent_backups_column_to_backups.py deleted file mode 100644 index 078ced0d70e..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/054_add_has_dependent_backups_column_to_backups.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) 2015 Huawei Technologies Co., Ltd. -# All Rights Reserved. -# -# 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, Integer, MetaData, Table - - -def upgrade(migrate_engine): - """Add num_dependent_backups column to backups.""" - meta = MetaData() - meta.bind = migrate_engine - - backups = Table('backups', meta, autoload=True) - num_dependent_backups = Column('num_dependent_backups', Integer, default=0) - backups.create_column(num_dependent_backups) - backups_list = list(backups.select().execute()) - for backup in backups_list: - dep_bks_list = list(backups.select().where(backups.columns.parent_id == - backup.id).execute()) - if dep_bks_list: - backups.update().where(backups.columns.id == backup.id).values( - num_dependent_backups=len(dep_bks_list)).execute() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/055_add_image_volume_cache_table.py b/cinder/db/sqlalchemy/migrate_repo/versions/055_add_image_volume_cache_table.py deleted file mode 100644 index 5d509a333b9..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/055_add_image_volume_cache_table.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2015 Pure Storage, Inc. -# -# 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, DateTime, Integer -from sqlalchemy import MetaData, String, Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - # New table - image_volume_cache = Table( - 'image_volume_cache_entries', meta, - Column('image_updated_at', DateTime(timezone=False)), - Column('id', Integer, primary_key=True, nullable=False), - Column('host', String(length=255), index=True, nullable=False), - Column('image_id', String(length=36), index=True, nullable=False), - Column('volume_id', String(length=36), nullable=False), - Column('size', Integer, nullable=False), - Column('last_used', DateTime, nullable=False), - mysql_engine='InnoDB', - mysql_charset='utf8' - ) - - image_volume_cache.create() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/056_placeholder.py b/cinder/db/sqlalchemy/migrate_repo/versions/056_placeholder.py deleted file mode 100644 index 37c8ad186a4..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/056_placeholder.py +++ /dev/null @@ -1,19 +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. - -# Do not use this number for new Mitaka work. New Mitaka work starts after -# all the placeholders. -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/057_placeholder.py b/cinder/db/sqlalchemy/migrate_repo/versions/057_placeholder.py deleted file mode 100644 index e31c02cf175..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/057_placeholder.py +++ /dev/null @@ -1,19 +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. - -# Do not use this number for new Kilo work. New Kilo work starts after -# all the placeholders. -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/058_placeholder.py b/cinder/db/sqlalchemy/migrate_repo/versions/058_placeholder.py deleted file mode 100644 index e31c02cf175..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/058_placeholder.py +++ /dev/null @@ -1,19 +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. - -# Do not use this number for new Kilo work. New Kilo work starts after -# all the placeholders. -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/059_placeholder.py b/cinder/db/sqlalchemy/migrate_repo/versions/059_placeholder.py deleted file mode 100644 index e31c02cf175..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/059_placeholder.py +++ /dev/null @@ -1,19 +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. - -# Do not use this number for new Kilo work. New Kilo work starts after -# all the placeholders. -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/060_placeholder.py b/cinder/db/sqlalchemy/migrate_repo/versions/060_placeholder.py deleted file mode 100644 index e31c02cf175..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/060_placeholder.py +++ /dev/null @@ -1,19 +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. - -# Do not use this number for new Kilo work. New Kilo work starts after -# all the placeholders. -# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html - - -def upgrade(migrate_engine): - pass diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/061_add_snapshot_id_timestamp_to_backups.py b/cinder/db/sqlalchemy/migrate_repo/versions/061_add_snapshot_id_timestamp_to_backups.py deleted file mode 100644 index 054cef34153..00000000000 --- a/cinder/db/sqlalchemy/migrate_repo/versions/061_add_snapshot_id_timestamp_to_backups.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) 2015 EMC Corporation -# All Rights Reserved. -# -# 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, DateTime, MetaData, String, Table - - -def upgrade(migrate_engine): - meta = MetaData() - meta.bind = migrate_engine - - backups = Table('backups', meta, autoload=True) - snapshot_id = Column('snapshot_id', String(length=36)) - data_timestamp = Column('data_timestamp', DateTime) - - backups.create_column(snapshot_id) - - backups.create_column(data_timestamp) - backups.update().values(data_timestamp=backups.c.created_at).execute() diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/046_cinder_init.py b/cinder/db/sqlalchemy/migrate_repo/versions/061_cinder_init.py similarity index 93% rename from cinder/db/sqlalchemy/migrate_repo/versions/046_cinder_init.py rename to cinder/db/sqlalchemy/migrate_repo/versions/061_cinder_init.py index b77336c95c2..e174d712e18 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/046_cinder_init.py +++ b/cinder/db/sqlalchemy/migrate_repo/versions/061_cinder_init.py @@ -48,6 +48,10 @@ def define_tables(meta): Column('availability_zone', String(255)), Column('disabled_reason', String(255)), Column('modified_at', DateTime(timezone=False)), + Column('rpc_current_version', String(36)), + Column('rpc_available_version', String(36)), + Column('object_current_version', String(36)), + Column('object_available_version', String(36)), mysql_engine='InnoDB', mysql_charset='utf8' ) @@ -68,6 +72,7 @@ def define_tables(meta): Column('volume_type_id', String(255)), Column('status', String(255)), Column('cgsnapshot_id', String(36)), + Column('source_cgid', String(36)), mysql_engine='InnoDB', mysql_charset='utf8' ) @@ -128,6 +133,7 @@ def define_tables(meta): ForeignKey('consistencygroups.id')), Column('provider_id', String(255)), Column('multiattach', Boolean), + Column('previous_status', String(255)), mysql_engine='InnoDB', mysql_charset='utf8' ) @@ -176,6 +182,7 @@ def define_tables(meta): Column('cgsnapshot_id', String(36), ForeignKey('cgsnapshots.id')), Column('provider_id', String(255)), + Column('provider_auth', String(255)), mysql_engine='InnoDB', mysql_charset='utf8' ) @@ -283,6 +290,7 @@ def define_tables(meta): Column('project_id', String(255)), Column('resource', String(255), nullable=False), Column('hard_limit', Integer), + Column('allocated', Integer, default=0), mysql_engine='InnoDB', mysql_charset='utf8' ) @@ -396,6 +404,11 @@ def define_tables(meta): Column('size', Integer()), Column('object_count', Integer()), Column('parent_id', String(36)), + Column('temp_volume_id', String(36)), + Column('temp_snapshot_id', String(36)), + Column('num_dependent_backups', Integer, default=0), + Column('snapshot_id', String(36)), + Column('data_timestamp', DateTime), mysql_engine='InnoDB', mysql_charset='utf8' ) @@ -475,6 +488,19 @@ def define_tables(meta): mysql_charset='utf8' ) + image_volume_cache = Table( + 'image_volume_cache_entries', meta, + Column('image_updated_at', DateTime(timezone=False)), + Column('id', Integer, primary_key=True, nullable=False), + Column('host', String(255), index=True, nullable=False), + Column('image_id', String(36), index=True, nullable=False), + Column('volume_id', String(36), nullable=False), + Column('size', Integer, nullable=False), + Column('last_used', DateTime, nullable=False), + mysql_engine='InnoDB', + mysql_charset='utf8' + ) + return [consistencygroups, cgsnapshots, volumes, @@ -497,7 +523,8 @@ def define_tables(meta): transfers, encryption, volume_admin_metadata, - initiator_data] + initiator_data, + image_volume_cache] def upgrade(migrate_engine): @@ -535,7 +562,8 @@ def upgrade(migrate_engine): "transfers", "encryption", "volume_admin_metadata", - "driver_initiator_data"] + "driver_initiator_data", + "image_volume_cache_entries"] migrate_engine.execute("SET foreign_key_checks = 0") for table in tables: @@ -572,3 +600,8 @@ def upgrade(migrate_engine): 'resource': 'consistencygroups', 'hard_limit': CONF.quota_consistencygroups, 'deleted': False, }) + qci.execute({'created_at': CREATED_AT, + 'class_name': CLASS_NAME, + 'resource': 'per_volume_gigabytes', + 'hard_limit': -1, + 'deleted': False, }) diff --git a/releasenotes/notes/db-schema-from-liberty-f5fa57d67441dece.yaml b/releasenotes/notes/db-schema-from-liberty-f5fa57d67441dece.yaml new file mode 100644 index 00000000000..318cb435b7e --- /dev/null +++ b/releasenotes/notes/db-schema-from-liberty-f5fa57d67441dece.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - The Cinder database can now only be upgraded from changes since the + Liberty release. In order to upgrade from a version prior to that, + you must now upgrade to at least Liberty first, then to Ocata or + later.