Merge "Add a new index on revocation_event table"

This commit is contained in:
Zuul
2025-12-05 18:11:18 +00:00
committed by Gerrit Code Review
5 changed files with 74 additions and 2 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.
"""Add index in revocation_event
Revision ID: 742c857f1dfb
Revises: e8725d6fa226
Create Date: 2025-11-24 10:21:03.202908
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '742c857f1dfb'
down_revision = 'e8725d6fa226'
branch_labels = None
depends_on = None
def upgrade():
op.create_index(
'ix_revocation_event_project_id_user_id',
'revocation_event',
['project_id', 'user_id'],
)
op.create_index(
'ix_revocation_event_composite',
'revocation_event',
['issued_before', 'user_id', 'project_id', 'audit_id'],
)

View File

@@ -1 +1 @@
e8725d6fa226
742c857f1dfb

View File

@@ -37,7 +37,7 @@ EXPAND_BRANCH = 'expand'
DATA_MIGRATION_BRANCH = 'data_migration'
CONTRACT_BRANCH = 'contract'
RELEASES = ('yoga', 'bobcat', '2024.1', '2025.2')
RELEASES = ('yoga', 'bobcat', '2024.1', '2025.2', '2026.1')
MILESTONES = (
'yoga',
# Do not add the milestone until the end of the release

View File

@@ -53,6 +53,16 @@ class RevocationEvent(sql.ModelBase, sql.ModelDictMixin):
'audit_id',
'issued_before',
),
sql.Index(
'ix_revocation_event_project_id_user_id', 'project_id', 'user_id'
),
sql.Index(
'ix_revocation_event_composite',
'issued_before',
'user_id',
'project_id',
'audit_id',
),
)

View File

@@ -329,6 +329,28 @@ class KeystoneMigrationsWalk(test_fixtures.OpportunisticDBTestMixin):
indexes = inspector.get_indexes('project_endpoint_group')
self.assertIn('idx_project_id', {x['name'] for x in indexes})
def _pre_upgrade_742c857f1dfb(self, connection):
inspector = sqlalchemy.inspect(connection)
indexes = inspector.get_indexes('revocation_event')
self.assertNotIn(
'ix_revocation_event_project_id_user_id',
{x['name'] for x in indexes},
)
self.assertNotIn(
'ix_revocation_event_composite', {x['name'] for x in indexes}
)
def _check_742c857f1dfb(self, connection):
inspector = sqlalchemy.inspect(connection)
indexes = inspector.get_indexes('revocation_event')
self.assertIn(
'ix_revocation_event_project_id_user_id',
{x['name'] for x in indexes},
)
self.assertIn(
'ix_revocation_event_composite', {x['name'] for x in indexes}
)
def test_single_base_revision(self):
"""Ensure we only have a single base revision.