diff --git a/neutron/db/migration/alembic_migrations/versions/EXPAND_HEAD b/neutron/db/migration/alembic_migrations/versions/EXPAND_HEAD index 99229550c74..ae416390415 100644 --- a/neutron/db/migration/alembic_migrations/versions/EXPAND_HEAD +++ b/neutron/db/migration/alembic_migrations/versions/EXPAND_HEAD @@ -1 +1 @@ -4e6e655746f6 +659cbedf30a1 diff --git a/neutron/db/migration/alembic_migrations/versions/zed/expand/659cbedf30a1_add_index_to_subnetpools_address_scope_.py b/neutron/db/migration/alembic_migrations/versions/zed/expand/659cbedf30a1_add_index_to_subnetpools_address_scope_.py new file mode 100644 index 00000000000..4b8050e75a5 --- /dev/null +++ b/neutron/db/migration/alembic_migrations/versions/zed/expand/659cbedf30a1_add_index_to_subnetpools_address_scope_.py @@ -0,0 +1,35 @@ +# Copyright 2022 OpenStack Foundation +# +# 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 alembic import op + + +"""add index to subnetpools address_scope_id + +Revision ID: 659cbedf30a1 +Revises: 4e6e655746f6 +Create Date: 2022-06-01 13:39:35.303265 + +""" + +# revision identifiers, used by Alembic. +revision = '659cbedf30a1' +down_revision = '4e6e655746f6' + + +def upgrade(): + index_name = 'ix_subnetpools_address_scope_id' + op.create_index(index_name, 'subnetpools', ['address_scope_id'], + unique=False) diff --git a/neutron/db/models_v2.py b/neutron/db/models_v2.py index e7e02c0f9d6..75d39f36f4c 100644 --- a/neutron/db/models_v2.py +++ b/neutron/db/models_v2.py @@ -275,7 +275,7 @@ class SubnetPool(standard_attr.HasStandardAttributes, model_base.BASEV2, server_default=sql.false()) default_quota = sa.Column(sa.Integer, nullable=True) hash = sa.Column(sa.String(36), nullable=False, server_default='') - address_scope_id = sa.Column(sa.String(36), nullable=True) + address_scope_id = sa.Column(sa.String(36), nullable=True, index=True) prefixes = orm.relationship(SubnetPoolPrefix, backref='subnetpools', cascade='all, delete, delete-orphan',