"""Make musehub_pack_index global — drop repo_id column and its FK. Pack index entries are content-addressed: the same object_id+pack_id pair is valid for every repo that has ever pushed those bytes. repo_id was the wrong abstraction and caused wire_fetch_mpack to miss packs from other repos (same objects, different repo). PK (object_id, pack_id) is unchanged. Drop the (repo_id, object_id) index and replace it with a plain object_id index — lookups are now global, not per-repo. """ from __future__ import annotations import sqlalchemy as sa from alembic import op revision = "0062" down_revision = "0061" branch_labels = None depends_on = None def upgrade() -> None: op.drop_index("ix_musehub_pack_index_repo_object", table_name="musehub_pack_index") op.drop_constraint("musehub_pack_index_repo_id_fkey", "musehub_pack_index", type_="foreignkey") op.drop_column("musehub_pack_index", "repo_id") op.create_index("ix_musehub_pack_index_object_id", "musehub_pack_index", ["object_id"]) def downgrade() -> None: op.drop_index("ix_musehub_pack_index_object_id", table_name="musehub_pack_index") op.add_column( "musehub_pack_index", sa.Column("repo_id", sa.String(128), nullable=False, server_default=""), ) op.create_foreign_key( "musehub_pack_index_repo_id_fkey", "musehub_pack_index", "musehub_repos", ["repo_id"], ["repo_id"], ondelete="CASCADE", ) op.create_index( "ix_musehub_pack_index_repo_object", "musehub_pack_index", ["repo_id", "object_id"], )