diff --git a/placement/db/sqlalchemy/alembic/versions/a082b8bb98d0_drop_redundant_indexes_for_unique_.py b/placement/db/sqlalchemy/alembic/versions/a082b8bb98d0_drop_redundant_indexes_for_unique_.py new file mode 100644 index 000000000..437079c3d --- /dev/null +++ b/placement/db/sqlalchemy/alembic/versions/a082b8bb98d0_drop_redundant_indexes_for_unique_.py @@ -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') diff --git a/placement/db/sqlalchemy/models.py b/placement/db/sqlalchemy/models.py index ad388410f..1bbdd4d0c 100644 --- a/placement/db/sqlalchemy/models.py +++ b/placement/db/sqlalchemy/models.py @@ -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):