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
33 changes: 33 additions & 0 deletions backend/alembic/versions/0097_roms_platform_fs_size_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Add composite index on roms (platform_id, fs_size_bytes)

Revision ID: 0097_roms_platform_fs_size_index
Revises: 0096_fix_virtual_collections
Create Date: 2026-07-16 00:00:00.000000

"""

from alembic import op

Check failure on line 9 in backend/alembic/versions/0097_roms_platform_fs_size_index.py

View workflow job for this annotation

GitHub Actions / Trunk Check

mypy(attr-defined)

[new] Module "alembic" has no attribute "op"

# revision identifiers, used by Alembic.
revision = "0097_roms_platform_fs_size_index"
down_revision = "0096_fix_virtual_collections"
branch_labels = None
depends_on = None

INDEX_NAME = "idx_roms_platform_fs_size"
INDEX_COLUMNS = ["platform_id", "fs_size_bytes"]


def upgrade() -> None:
with op.batch_alter_table("roms", schema=None) as batch_op:
batch_op.create_index(
INDEX_NAME,
INDEX_COLUMNS,
unique=False,
if_not_exists=True,
)


def downgrade() -> None:
with op.batch_alter_table("roms", schema=None) as batch_op:
batch_op.drop_index(INDEX_NAME, if_exists=True)
1 change: 1 addition & 0 deletions backend/models/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ class Rom(BaseModel):
"tgdb_id",
"id",
),
Index("idx_roms_platform_fs_size", "platform_id", "fs_size_bytes"),
Index("idx_roms_name", "name"),
Index("idx_roms_name_sort_key", "name_sort_key"),
Index("idx_roms_igdb_id", "igdb_id"),
Expand Down
Loading