65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
"""user: add events
|
|
|
|
Revision ID: 198227d190b8
|
|
Revises: b6a304d96a2d
|
|
Create Date: 2025-08-12 15:12:49.860825
|
|
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Sequence
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlmodel
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "198227d190b8"
|
|
down_revision: str | Sequence[str] | None = "b6a304d96a2d"
|
|
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(
|
|
"user_events",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column(
|
|
"type",
|
|
sa.Enum(
|
|
"ACHIEVEMENT",
|
|
"BEATMAP_PLAYCOUNT",
|
|
"BEATMAPSET_APPROVE",
|
|
"BEATMAPSET_DELETE",
|
|
"BEATMAPSET_REVIVE",
|
|
"BEATMAPSET_UPDATE",
|
|
"BEATMAPSET_UPLOAD",
|
|
"RANK",
|
|
"RANK_LOST",
|
|
"USERNAME_CHANGE",
|
|
name="eventtype",
|
|
),
|
|
nullable=False,
|
|
),
|
|
sa.Column("event_payload", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column("user_id", sa.BigInteger(), nullable=True),
|
|
sa.ForeignKeyConstraint(
|
|
["user_id"],
|
|
["lazer_users.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_user_events_user_id"), "user_events", ["user_id"], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table("user_events")
|
|
# ### end Alembic commands ###
|