Files
g0v0-server/migrations/versions/2025-11-22_3f0f22f38c3d_matchmaking_sync_with_osu_web.py
2025-11-22 13:15:24 +00:00

62 lines
2.4 KiB
Python

"""matchmaking: sync with osu-web
Revision ID: 3f0f22f38c3d
Revises: a7646e082906
Create Date: 2025-11-22 12:45:36.767097
"""
from collections.abc import Sequence
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision: str = "3f0f22f38c3d"
down_revision: str | Sequence[str] | None = "a7646e082906"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("matchmaking_pools_ruleset_variant_active_idx"), table_name="matchmaking_pools")
op.create_index("matchmaking_pools_ruleset_active_idx", "matchmaking_pools", ["ruleset_id", "active"], unique=False)
op.drop_column("matchmaking_pools", "variant_id")
op.add_column("matchmaking_user_stats", sa.Column("pool_id", sa.Integer(), nullable=True))
op.create_index(
"matchmaking_user_stats_pool_first_idx", "matchmaking_user_stats", ["pool_id", "first_placements"], unique=False
)
op.create_index(
"matchmaking_user_stats_pool_points_idx", "matchmaking_user_stats", ["pool_id", "total_points"], unique=False
)
op.create_foreign_key(None, "matchmaking_user_stats", "matchmaking_pools", ["pool_id"], ["id"])
op.drop_column("matchmaking_user_stats", "ruleset_id")
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"matchmaking_user_stats",
sa.Column("ruleset_id", mysql.SMALLINT(), nullable=False, server_default="0"),
)
op.drop_index("matchmaking_user_stats_pool_points_idx", table_name="matchmaking_user_stats")
op.drop_index("matchmaking_user_stats_pool_first_idx", table_name="matchmaking_user_stats")
op.drop_column("matchmaking_user_stats", "pool_id")
op.add_column(
"matchmaking_pools",
sa.Column("variant_id", mysql.SMALLINT(), nullable=False, server_default="0"),
)
op.drop_index("matchmaking_pools_ruleset_active_idx", table_name="matchmaking_pools")
op.create_index(
"matchmaking_pools_ruleset_variant_active_idx",
"matchmaking_pools",
["ruleset_id", "variant_id", "active"],
unique=False,
)
# ### end Alembic commands ###