feat: add Alembic migrations and category seed data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mathew Sir Guest the best
2026-05-06 22:42:52 -06:00
co-authored by Claude Opus 4.6
parent e483d1127a
commit c1f7ed44c1
7 changed files with 483 additions and 0 deletions
@@ -0,0 +1,85 @@
"""initial tables
Revision ID: 71016fe57b9d
Revises:
Create Date: 2026-05-06 22:42:01.575740
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "71016fe57b9d"
down_revision: Union[str, Sequence[str], None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"categories",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("name", sa.String(length=50), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("name"),
)
op.create_table(
"category_words",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("category_id", sa.Integer(), nullable=False),
sa.Column("word", sa.String(length=20), nullable=False),
sa.ForeignKeyConstraint(
["category_id"],
["categories.id"],
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("category_id", "word"),
)
op.create_table(
"games",
sa.Column("id", sa.String(length=36), nullable=False),
sa.Column("category_id", sa.Integer(), nullable=False),
sa.Column("board_size", sa.Integer(), nullable=False),
sa.Column("grid", sa.JSON(), nullable=False),
sa.Column("status", sa.String(length=20), nullable=False),
sa.Column("started_at", sa.DateTime(), nullable=False),
sa.Column("completed_at", sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(
["category_id"],
["categories.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"words",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("game_id", sa.String(length=36), nullable=False),
sa.Column("text", sa.String(length=20), nullable=False),
sa.Column("start_row", sa.Integer(), nullable=False),
sa.Column("start_col", sa.Integer(), nullable=False),
sa.Column("direction", sa.String(length=2), nullable=False),
sa.Column("found", sa.Boolean(), nullable=False),
sa.Column("found_at", sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(
["game_id"],
["games.id"],
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("words")
op.drop_table("games")
op.drop_table("category_words")
op.drop_table("categories")
# ### end Alembic commands ###