Files
classquiz-ai/migrations/versions/438516c09cf3_added_game_results.py
T
2023-06-30 13:16:12 +02:00

51 lines
1.7 KiB
Python

# SPDX-FileCopyrightText: 2023 Marlon W (Mawoka)
#
# SPDX-License-Identifier: MPL-2.0
"""Added game_results
Revision ID: 438516c09cf3
Revises: 7ad8502af419
Create Date: 2023-02-13 17:34:05.358665
"""
from alembic import op
import sqlalchemy as sa
import ormar
# revision identifiers, used by Alembic.
revision = "438516c09cf3"
down_revision = "7ad8502af419"
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"game_results",
sa.Column("id", ormar.fields.sqlalchemy_uuid.CHAR(32), nullable=False),
sa.Column("quiz", ormar.fields.sqlalchemy_uuid.CHAR(32), nullable=True),
sa.Column("user", ormar.fields.sqlalchemy_uuid.CHAR(32), nullable=True),
sa.Column("timestamp", sa.DateTime(), nullable=False),
sa.Column("player_count", sa.Integer(), nullable=False),
sa.Column("note", sa.Text(), nullable=True),
sa.Column("answers", sa.JSON(), nullable=False),
sa.Column("player_scores", sa.JSON(none_as_null=True), nullable=True),
sa.Column("custom_field_data", sa.JSON(none_as_null=True), nullable=True),
sa.Column("title", sa.Text(), nullable=False),
sa.Column("description", sa.Text(), nullable=False),
sa.Column("questions", sa.JSON(), nullable=False),
sa.ForeignKeyConstraint(["quiz"], ["quiz.id"], name="fk_game_results_quiz_id_quiz"),
sa.ForeignKeyConstraint(["user"], ["users.id"], name="fk_game_results_users_id_user"),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("game_results")
# ### end Alembic commands ###