feat(user): support global rank & country rank
This commit is contained in:
113
migrations/versions/b6a304d96a2d_user_support_rank.py
Normal file
113
migrations/versions/b6a304d96a2d_user_support_rank.py
Normal file
@@ -0,0 +1,113 @@
|
||||
"""user: support rank
|
||||
|
||||
Revision ID: b6a304d96a2d
|
||||
Revises: 749bb2c2c33a
|
||||
Create Date: 2025-08-12 13:31:45.315844
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
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 = "b6a304d96a2d"
|
||||
down_revision: str | Sequence[str] | None = "749bb2c2c33a"
|
||||
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.create_table(
|
||||
"rank_history",
|
||||
sa.Column("id", sa.BigInteger(), nullable=False),
|
||||
sa.Column("user_id", sa.BigInteger(), nullable=True),
|
||||
sa.Column(
|
||||
"mode",
|
||||
sa.Enum(
|
||||
"OSU", "TAIKO", "FRUITS", "MANIA", "OSURX", "OSUAP", name="gamemode"
|
||||
),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("rank", sa.Integer(), nullable=False),
|
||||
sa.Column("date", sa.Date(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["user_id"],
|
||||
["lazer_users.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_rank_history_date"), "rank_history", ["date"], unique=False
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_rank_history_user_id"), "rank_history", ["user_id"], unique=False
|
||||
)
|
||||
op.create_table(
|
||||
"rank_top",
|
||||
sa.Column("id", sa.BigInteger(), nullable=False),
|
||||
sa.Column("user_id", sa.BigInteger(), nullable=True),
|
||||
sa.Column(
|
||||
"mode",
|
||||
sa.Enum(
|
||||
"OSU", "TAIKO", "FRUITS", "MANIA", "OSURX", "OSUAP", name="gamemode"
|
||||
),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("rank", sa.Integer(), nullable=False),
|
||||
sa.Column("date", sa.Date(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["user_id"],
|
||||
["lazer_users.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(op.f("ix_rank_top_date"), "rank_top", ["date"], unique=False)
|
||||
op.create_index(op.f("ix_rank_top_user_id"), "rank_top", ["user_id"], unique=False)
|
||||
op.create_index(
|
||||
op.f("ix_lazer_user_statistics_mode"),
|
||||
"lazer_user_statistics",
|
||||
["mode"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_lazer_user_statistics_pp"),
|
||||
"lazer_user_statistics",
|
||||
["pp"],
|
||||
unique=False,
|
||||
)
|
||||
op.drop_column("lazer_user_statistics", "country_rank")
|
||||
op.drop_column("lazer_user_statistics", "global_rank")
|
||||
op.create_index(
|
||||
op.f("ix_oauth_clients_name"), "oauth_clients", ["name"], unique=False
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f("ix_oauth_clients_name"), table_name="oauth_clients")
|
||||
op.add_column(
|
||||
"lazer_user_statistics",
|
||||
sa.Column("global_rank", mysql.INTEGER(), autoincrement=False, nullable=True),
|
||||
)
|
||||
op.add_column(
|
||||
"lazer_user_statistics",
|
||||
sa.Column("country_rank", mysql.INTEGER(), autoincrement=False, nullable=True),
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_lazer_user_statistics_pp"), table_name="lazer_user_statistics"
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_lazer_user_statistics_mode"), table_name="lazer_user_statistics"
|
||||
)
|
||||
op.drop_table("rank_top")
|
||||
op.drop_table("rank_history")
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user