Db: Drop redundant indexes for columns already having unique constraint

* inventories.provider_id
 * inventories.resource_class
 * placement_aggregates.uuid
 * resource_providers.name
 * resource_providers.uuid

Story: 2010251
Task: 46118

Change-Id: Ia834a991edf8f21ee9bea7f97399cd6c003b54e5
This commit is contained in:
Christian Rohmann 2022-09-09 15:54:14 +02:00
parent 5ec38f6d3b
commit 0a8c7c5a9e
2 changed files with 41 additions and 7 deletions

View File

@ -0,0 +1,40 @@
# 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 redundant indexes for unique constraints
Revision ID: a082b8bb98d0
Revises: 422ece571366
Create Date: 2022-09-09 15:52:21.644040
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = 'a082b8bb98d0'
down_revision = '422ece571366'
branch_labels = None
depends_on = None
def upgrade():
op.drop_index('inventories_resource_provider_id_idx',
table_name='inventories')
op.drop_index('inventories_resource_provider_resource_class_idx',
table_name='inventories')
op.drop_index('ix_placement_aggregates_uuid',
table_name='placement_aggregates')
op.drop_index('resource_providers_name_idx',
table_name='resource_providers')
op.drop_index('resource_providers_uuid_idx',
table_name='resource_providers')

View File

@ -50,9 +50,7 @@ class ResourceProvider(BASE):
__tablename__ = "resource_providers"
__table_args__ = (
Index('resource_providers_uuid_idx', 'uuid'),
schema.UniqueConstraint('uuid', name='uniq_resource_providers0uuid'),
Index('resource_providers_name_idx', 'name'),
Index('resource_providers_root_provider_id_idx',
'root_provider_id'),
Index('resource_providers_parent_provider_id_idx',
@ -78,12 +76,8 @@ class Inventory(BASE):
__tablename__ = "inventories"
__table_args__ = (
Index('inventories_resource_provider_id_idx',
'resource_provider_id'),
Index('inventories_resource_class_id_idx',
'resource_class_id'),
Index('inventories_resource_provider_resource_class_idx',
'resource_provider_id', 'resource_class_id'),
schema.UniqueConstraint(
'resource_provider_id', 'resource_class_id',
name='uniq_inventories0resource_provider_resource_class')
@ -151,7 +145,7 @@ class PlacementAggregate(BASE):
)
id = Column(Integer, primary_key=True, autoincrement=True)
uuid = Column(String(36), index=True)
uuid = Column(String(36))
class Trait(BASE):