This commit is contained in:
2025-12-22 14:47:25 -05:00
parent d4e859f9a7
commit 00e9eb8986
81 changed files with 13933 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
"""Add Category model
Revision ID: 01a0ed14f3eb
Revises: 6347615a68b5
Create Date: 2025-12-08 20:13:22.898643
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '01a0ed14f3eb'
down_revision = '6347615a68b5'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('categories',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('categories')
# ### end Alembic commands ###

View File

@@ -0,0 +1,32 @@
"""add phone_a_friend_count to teams
Revision ID: 1252454a2589
Revises: 01a0ed14f3eb
Create Date: 2025-12-14 19:23:42.244820
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1252454a2589'
down_revision = '01a0ed14f3eb'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('teams', schema=None) as batch_op:
batch_op.add_column(sa.Column('phone_a_friend_count', sa.Integer(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('teams', schema=None) as batch_op:
batch_op.drop_column('phone_a_friend_count')
# ### end Alembic commands ###

View File

@@ -0,0 +1,38 @@
"""Add category and is_template fields
Revision ID: 6347615a68b5
Revises: c949c8fe106a
Create Date: 2025-12-08 20:08:41.878117
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6347615a68b5'
down_revision = 'c949c8fe106a'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('games', schema=None) as batch_op:
batch_op.add_column(sa.Column('is_template', sa.Boolean(), nullable=True))
with op.batch_alter_table('questions', schema=None) as batch_op:
batch_op.add_column(sa.Column('category', sa.String(length=100), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('questions', schema=None) as batch_op:
batch_op.drop_column('category')
with op.batch_alter_table('games', schema=None) as batch_op:
batch_op.drop_column('is_template')
# ### end Alembic commands ###

View File

@@ -0,0 +1,41 @@
"""Add User model for OIDC authentication
Revision ID: 6d457de4e2b1
Revises: fc2ec8c4e929
Create Date: 2025-12-21 10:01:19.224313
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6d457de4e2b1'
down_revision = 'fc2ec8c4e929'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('authelia_sub', sa.String(length=255), nullable=False),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('preferred_username', sa.String(length=100), nullable=True),
sa.Column('groups', sa.JSON(), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('last_login', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('authelia_sub'),
sa.UniqueConstraint('email')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('users')
# ### end Alembic commands ###

View File

@@ -0,0 +1,36 @@
"""Make user email nullable
Revision ID: 90b81e097444
Revises: 6d457de4e2b1
Create Date: 2025-12-21 20:18:36.820920
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '90b81e097444'
down_revision = '6d457de4e2b1'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.alter_column('email',
existing_type=sa.VARCHAR(length=255),
nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.alter_column('email',
existing_type=sa.VARCHAR(length=255),
nullable=False)
# ### end Alembic commands ###

View File

@@ -0,0 +1,78 @@
"""Initial migration with all models
Revision ID: c949c8fe106a
Revises:
Create Date: 2025-12-08 09:35:40.713069
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c949c8fe106a'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('games',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=200), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.Column('current_question_index', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('questions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('type', sa.Enum('TEXT', 'IMAGE', name='questiontype'), nullable=False),
sa.Column('question_content', sa.Text(), nullable=False),
sa.Column('answer', sa.Text(), nullable=False),
sa.Column('image_path', sa.String(length=255), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('game_questions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('game_id', sa.Integer(), nullable=False),
sa.Column('question_id', sa.Integer(), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['game_id'], ['games.id'], ),
sa.ForeignKeyConstraint(['question_id'], ['questions.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('game_id', 'order', name='unique_game_question_order')
)
op.create_table('teams',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('game_id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['game_id'], ['games.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('scores',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('team_id', sa.Integer(), nullable=False),
sa.Column('game_id', sa.Integer(), nullable=False),
sa.Column('question_index', sa.Integer(), nullable=False),
sa.Column('points', sa.Integer(), nullable=True),
sa.Column('awarded_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['game_id'], ['games.id'], ),
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('team_id', 'question_index', name='unique_team_question_score')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('scores')
op.drop_table('teams')
op.drop_table('game_questions')
op.drop_table('questions')
op.drop_table('games')
# ### end Alembic commands ###

View File

@@ -0,0 +1,60 @@
"""Add YouTube audio support
Revision ID: fc2ec8c4e929
Revises: 1252454a2589
Create Date: 2025-12-20 21:07:01.804139
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'fc2ec8c4e929'
down_revision = '1252454a2589'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('download_jobs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('question_id', sa.Integer(), nullable=False),
sa.Column('celery_task_id', sa.String(length=255), nullable=False),
sa.Column('status', sa.Enum('PENDING', 'PROCESSING', 'COMPLETED', 'FAILED', name='downloadjobstatus'), nullable=False),
sa.Column('progress', sa.Integer(), nullable=True),
sa.Column('error_message', sa.Text(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('completed_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['question_id'], ['questions.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('celery_task_id')
)
with op.batch_alter_table('questions', schema=None) as batch_op:
batch_op.add_column(sa.Column('youtube_url', sa.String(length=500), nullable=True))
batch_op.add_column(sa.Column('audio_path', sa.String(length=255), nullable=True))
batch_op.add_column(sa.Column('start_time', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('end_time', sa.Integer(), nullable=True))
batch_op.alter_column('type',
existing_type=sa.VARCHAR(length=5),
type_=sa.Enum('TEXT', 'IMAGE', 'YOUTUBE_AUDIO', name='questiontype'),
existing_nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('questions', schema=None) as batch_op:
batch_op.alter_column('type',
existing_type=sa.Enum('TEXT', 'IMAGE', 'YOUTUBE_AUDIO', name='questiontype'),
type_=sa.VARCHAR(length=5),
existing_nullable=False)
batch_op.drop_column('end_time')
batch_op.drop_column('start_time')
batch_op.drop_column('audio_path')
batch_op.drop_column('youtube_url')
op.drop_table('download_jobs')
# ### end Alembic commands ###