Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-License-Identifier: Apache-2.0
"""
Add reverse ID index for journals

Revision ID: 7cf64da2632a
Revises: 4c20f2342bba
Create Date: 2025-11-14 18:14:43.440919
"""

import sqlalchemy as sa

from alembic import op

revision = "7cf64da2632a"
down_revision = "4c20f2342bba"


def upgrade():
# CREATE INDEX CONCURRENTLY cannot happen inside a transaction. We'll close
# our transaction here and issue the statement.
op.get_bind().commit()

with op.get_context().autocommit_block():
op.create_index(
"journals_name_id_idx",
"journals",
["name", sa.literal_column("id DESC")],
unique=False,
postgresql_concurrently=True,
)


def downgrade():
op.drop_index("journals_name_id_idx", table_name="journals")
6 changes: 6 additions & 0 deletions warehouse/packaging/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,12 @@ def __table_args__(cls): # noqa
cls._submitted_by,
cls.submitted_date.desc(),
),
# Reverse index on ID, most recent project's journal entry for triggers
Index(
"journals_name_id_idx",
cls.name,
cls.id.desc(),
),
)

id: Mapped[int] = mapped_column(primary_key=True)
Expand Down