"""Add musehub_fetch_mpack_cache table. Pre-built fetch mpacks are cached here after every push so that wire_fetch_mpack can return a presigned URL immediately (sub-second) instead of building the mpack synchronously in the request path. Revision ID: 0071 Revises: 0070 """ from __future__ import annotations import sqlalchemy as sa from alembic import op revision: str = "0071" down_revision: str = "0070" branch_labels = None depends_on = None def upgrade() -> None: op.create_table( "musehub_fetch_mpack_cache", sa.Column("cache_id", sa.String(128), primary_key=True), sa.Column("repo_id", sa.String(128), nullable=False), sa.Column("tip_commit_id", sa.String(128), nullable=False), sa.Column("mpack_id", sa.String(128), nullable=False), sa.Column( "created_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.text("now()"), ), sa.Column( "expires_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.text("now() + interval '7 days'"), ), ) op.create_index( "ix_fetch_mpack_cache_repo_tip", "musehub_fetch_mpack_cache", ["repo_id", "tip_commit_id"], unique=True, ) op.create_index( "ix_fetch_mpack_cache_expires_at", "musehub_fetch_mpack_cache", ["expires_at"], ) def downgrade() -> None: op.drop_index("ix_fetch_mpack_cache_expires_at", table_name="musehub_fetch_mpack_cache") op.drop_index("ix_fetch_mpack_cache_repo_tip", table_name="musehub_fetch_mpack_cache") op.drop_table("musehub_fetch_mpack_cache")