- Introduced a new `spin_sessions` table to track user spin activities. - Updated the API to include a new endpoint for spinning games, allowing users to place bets and specify spin counts. - Enhanced game information structure and added validation for bets and spin counts. - Implemented the `Forest Fortune` slot game mechanics, including payline evaluation and scatter functionality. - Updated dependencies in `pyproject.toml` for development and added `httpx` for HTTP requests. - Added unit tests for the new slot mechanics and API endpoints to ensure functionality and reliability.
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
"""Add spin_sessions table."""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0002_spin_sessions"
|
|
down_revision: Union[str, None] = "0001_initial"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"spin_sessions",
|
|
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column("user_id", sa.Integer(), nullable=False),
|
|
sa.Column("slug", sa.String(length=64), nullable=False),
|
|
sa.Column("bet", sa.Numeric(18, 2), nullable=False),
|
|
sa.Column("spin_count", sa.Integer(), nullable=False),
|
|
sa.Column("total_win", sa.Numeric(18, 2), nullable=False),
|
|
sa.Column("payload_json", sa.Text(), nullable=False),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
nullable=False,
|
|
),
|
|
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index("ix_spin_sessions_user_id", "spin_sessions", ["user_id"], unique=False)
|
|
op.create_index("ix_spin_sessions_slug", "spin_sessions", ["slug"], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_spin_sessions_slug", table_name="spin_sessions")
|
|
op.drop_index("ix_spin_sessions_user_id", table_name="spin_sessions")
|
|
op.drop_table("spin_sessions")
|