diff --git a/neutron/db/migration/alembic_migrations/versions/EXPAND_HEAD b/neutron/db/migration/alembic_migrations/versions/EXPAND_HEAD index 1fabf4a11aa..e2ec2347a47 100644 --- a/neutron/db/migration/alembic_migrations/versions/EXPAND_HEAD +++ b/neutron/db/migration/alembic_migrations/versions/EXPAND_HEAD @@ -1 +1 @@ -c181bb1d89e4 +ba859d649675 diff --git a/neutron/db/migration/alembic_migrations/versions/yoga/expand/ba859d649675_add_indexes_to_rbacs.py b/neutron/db/migration/alembic_migrations/versions/yoga/expand/ba859d649675_add_indexes_to_rbacs.py new file mode 100644 index 00000000000..affd7e03fa0 --- /dev/null +++ b/neutron/db/migration/alembic_migrations/versions/yoga/expand/ba859d649675_add_indexes_to_rbacs.py @@ -0,0 +1,41 @@ +# Copyright 2021 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 indexes to RBACs + +Revision ID: ba859d649675 +Revises: c181bb1d89e4 +Create Date: 2021-09-20 15:22:04.668376 + +""" + +# revision identifiers, used by Alembic. +revision = 'ba859d649675' +down_revision = 'c181bb1d89e4' + +OBJECTS = ('network', 'qospolicy', 'securitygroup', 'addressscope', + 'subnetpool', 'addressgroup') +COLUMNS = ('target_tenant', 'action') + + +def upgrade(): + for object in OBJECTS: + table = object + 'rbacs' + ix = 'ix_' + table + '_' + for column in COLUMNS: + op.create_index(op.f(ix + column), table, [column], unique=False) diff --git a/neutron/db/rbac_db_models.py b/neutron/db/rbac_db_models.py index 149a5f9e345..59d167efb0f 100644 --- a/neutron/db/rbac_db_models.py +++ b/neutron/db/rbac_db_models.py @@ -47,9 +47,9 @@ class RBACColumns(model_base.HasId, model_base.HasProject): # also be a wildcard '*' to indicate all tenants or it may be a role if # neutron gets better integration with keystone target_tenant = sa.Column(sa.String(db_const.PROJECT_ID_FIELD_SIZE), - nullable=False) + nullable=False, index=True) - action = sa.Column(sa.String(255), nullable=False) + action = sa.Column(sa.String(255), nullable=False, index=True) @property @abc.abstractmethod