Merge "db: Compact Pike database migrations"
This commit is contained in:
commit
21e3d8ba5d
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +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.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,28 +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
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
for prefix in ('', 'shadow_'):
|
||||
table = Table(prefix + 'block_device_mapping', meta, autoload=True)
|
||||
new_column = Column('attachment_id', String(36), nullable=True)
|
||||
if not hasattr(table.c, 'attachment_id'):
|
||||
table.create_column(new_column)
|
|
@ -1,33 +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.engine.reflection import Inspector
|
||||
from sqlalchemy import Index
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import String
|
||||
from sqlalchemy import Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData(bind=migrate_engine)
|
||||
for prefix in ('', 'shadow_'):
|
||||
services = Table(prefix + 'services', meta, autoload=True)
|
||||
if not hasattr(services.c, 'uuid'):
|
||||
services.create_column(Column('uuid', String(36), nullable=True))
|
||||
|
||||
uuid_index_name = 'services_uuid_idx'
|
||||
indexes = Inspector(migrate_engine).get_indexes('services')
|
||||
if uuid_index_name not in (i['name'] for i in indexes):
|
||||
services = Table('services', meta, autoload=True)
|
||||
Index(uuid_index_name, services.c.uuid, unique=True).create()
|
|
@ -1,24 +0,0 @@
|
|||
# Copyright 2017 Red Hat, 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 MetaData, Table, Column, Integer
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData(bind=migrate_engine)
|
||||
|
||||
for prefix in ('', 'shadow_'):
|
||||
compute_nodes = Table('%scompute_nodes' % prefix, meta, autoload=True)
|
||||
mapped = Column('mapped', Integer, default=0, nullable=True)
|
||||
if not hasattr(compute_nodes.c, 'mapped'):
|
||||
compute_nodes.create_column(mapped)
|
|
@ -1,41 +0,0 @@
|
|||
# Copyright 2017 Huawei Technologies Co.,LTD.
|
||||
#
|
||||
# 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_log import log as logging
|
||||
from sqlalchemy import MetaData, Table, Index
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _get_table_index(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
table = Table('compute_nodes', meta, autoload=True)
|
||||
for idx in table.indexes:
|
||||
if idx.columns.keys() == ['uuid']:
|
||||
break
|
||||
else:
|
||||
idx = None
|
||||
return table, idx
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
table, index = _get_table_index(migrate_engine)
|
||||
if index:
|
||||
LOG.info('Skipped adding compute_nodes_uuid_idx because an '
|
||||
'equivalent index already exists.')
|
||||
return
|
||||
index = Index('compute_nodes_uuid_idx', table.c.uuid, unique=True)
|
||||
index.create(migrate_engine)
|
|
@ -1,36 +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_db.sqlalchemy import utils
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import String
|
||||
|
||||
from nova.db.sqlalchemy import api
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
shadow_prefix = api._SHADOW_TABLE_PREFIX
|
||||
uuid_col = Column('uuid', String(36))
|
||||
|
||||
pci_devices = utils.get_table(migrate_engine, 'pci_devices')
|
||||
if not hasattr(pci_devices.c, 'uuid'):
|
||||
pci_devices.create_column(uuid_col.copy())
|
||||
|
||||
shadow_pci_devices = utils.get_table(migrate_engine,
|
||||
shadow_prefix + 'pci_devices')
|
||||
if not hasattr(shadow_pci_devices.c, 'uuid'):
|
||||
shadow_pci_devices.create_column(uuid_col.copy())
|
|
@ -234,6 +234,7 @@ def upgrade(migrate_engine):
|
|||
Column('boot_index', Integer),
|
||||
Column('image_id', String(length=36), nullable=True),
|
||||
Column('tag', String(255)),
|
||||
Column('attachment_id', String(36), nullable=True),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
@ -322,6 +323,8 @@ def upgrade(migrate_engine):
|
|||
Column('cpu_allocation_ratio', Float, nullable=True),
|
||||
Column('uuid', String(36), nullable=True),
|
||||
Column('disk_allocation_ratio', Float, nullable=True),
|
||||
Column('mapped', Integer, default=0, nullable=True),
|
||||
Index('compute_nodes_uuid_idx', 'uuid', unique=True),
|
||||
UniqueConstraint(
|
||||
'host', 'hypervisor_hostname', 'deleted',
|
||||
name='uniq_compute_nodes0host0hypervisor_hostname0deleted',
|
||||
|
@ -864,6 +867,7 @@ def upgrade(migrate_engine):
|
|||
Column('request_id', String(36), nullable=True),
|
||||
Column('numa_node', Integer, default=None),
|
||||
Column('parent_addr', String(12), nullable=True),
|
||||
Column('uuid', String(36)),
|
||||
Index('ix_pci_devices_instance_uuid_deleted',
|
||||
'instance_uuid', 'deleted'),
|
||||
Index('ix_pci_devices_compute_node_id_deleted',
|
||||
|
@ -1079,6 +1083,8 @@ def upgrade(migrate_engine):
|
|||
# which did not generate the constraints
|
||||
Column('forced_down', Boolean(create_constraint=False), default=False),
|
||||
Column('version', Integer, default=0),
|
||||
Column('uuid', String(36), nullable=True),
|
||||
Index('services_uuid_idx', 'uuid', unique=True),
|
||||
UniqueConstraint(
|
||||
'host', 'topic', 'deleted',
|
||||
name='uniq_services0host0topic0deleted'),
|
||||
|
@ -1386,6 +1392,7 @@ def upgrade(migrate_engine):
|
|||
Index('networks_vlan_deleted_idx', networks.c.vlan,
|
||||
networks.c.deleted),
|
||||
|
||||
# pci_devices
|
||||
Index('ix_pci_devices_compute_node_id_parent_addr_deleted',
|
||||
pci_devices.c.compute_node_id,
|
||||
pci_devices.c.parent_addr,
|
|
@ -29,7 +29,7 @@ from nova import exception
|
|||
from nova.i18n import _
|
||||
|
||||
INIT_VERSION = {}
|
||||
INIT_VERSION['main'] = 346
|
||||
INIT_VERSION['main'] = 361
|
||||
INIT_VERSION['api'] = 0
|
||||
_REPOSITORY = {}
|
||||
|
||||
|
|
|
@ -163,7 +163,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
|||
self.INIT_VERSION + 1,
|
||||
]
|
||||
|
||||
ocata_placeholders = list(range(348, 358))
|
||||
pike_placeholders = list(range(363, 373))
|
||||
queens_placeholders = list(range(379, 389))
|
||||
# We forgot to add the rocky placeholder. We've also switched to 5
|
||||
|
@ -175,7 +174,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
|||
victoria_placeholders = list(range(413, 418))
|
||||
|
||||
return (special +
|
||||
ocata_placeholders +
|
||||
pike_placeholders +
|
||||
queens_placeholders +
|
||||
stein_placeholders +
|
||||
|
@ -236,26 +234,6 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
|||
def test_walk_versions(self):
|
||||
self.walk_versions(snake_walk=False, downgrade=False)
|
||||
|
||||
def _check_358(self, engine, data):
|
||||
self.assertColumnExists(engine, 'block_device_mapping',
|
||||
'attachment_id')
|
||||
|
||||
def _check_359(self, engine, data):
|
||||
self.assertColumnExists(engine, 'services', 'uuid')
|
||||
self.assertIndexMembers(engine, 'services', 'services_uuid_idx',
|
||||
['uuid'])
|
||||
|
||||
def _check_360(self, engine, data):
|
||||
self.assertColumnExists(engine, 'compute_nodes', 'mapped')
|
||||
self.assertColumnExists(engine, 'shadow_compute_nodes', 'mapped')
|
||||
|
||||
def _check_361(self, engine, data):
|
||||
self.assertIndexMembers(engine, 'compute_nodes',
|
||||
'compute_nodes_uuid_idx', ['uuid'])
|
||||
|
||||
def _check_362(self, engine, data):
|
||||
self.assertColumnExists(engine, 'pci_devices', 'uuid')
|
||||
|
||||
def _check_373(self, engine, data):
|
||||
self.assertColumnExists(engine, 'migrations', 'uuid')
|
||||
|
||||
|
|
Loading…
Reference in New Issue