mirror of
https://github.com/koloideal/Quizzi.git
synced 2026-06-10 18:35:28 +03:00
55 lines
2.0 KiB
Python
55 lines
2.0 KiB
Python
"""test attempts
|
|
|
|
Revision ID: f63140aa50c0
|
|
Revises: 59dd00dc1990
|
|
Create Date: 2026-01-01 16:26:43.398213
|
|
|
|
"""
|
|
from collections.abc import Sequence
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision: str = 'f63140aa50c0'
|
|
down_revision: str | None = '59dd00dc1990'
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('test_attempts',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.BigInteger(), nullable=False),
|
|
sa.Column('test_id', sa.Integer(), nullable=False),
|
|
sa.Column('started_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
|
sa.Column('finished_at', sa.DateTime(), nullable=True),
|
|
sa.Column('score', sa.Integer(), nullable=False),
|
|
sa.Column('is_passed', sa.Boolean(), nullable=False),
|
|
sa.ForeignKeyConstraint(['test_id'], ['tests.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_test_attempts_user_id'), 'test_attempts', ['user_id'], unique=False)
|
|
op.create_table('user_answers',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('attempt_id', sa.Integer(), nullable=False),
|
|
sa.Column('question_id', sa.Integer(), nullable=False),
|
|
sa.Column('selected_option_id', sa.Integer(), nullable=True),
|
|
sa.Column('text_answer', sa.Text(), nullable=True),
|
|
sa.Column('is_correct', sa.Boolean(), nullable=False),
|
|
sa.ForeignKeyConstraint(['attempt_id'], ['test_attempts.id'], ),
|
|
sa.ForeignKeyConstraint(['question_id'], ['questions.id'], ),
|
|
sa.ForeignKeyConstraint(['selected_option_id'], ['options.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('user_answers')
|
|
op.drop_index(op.f('ix_test_attempts_user_id'), table_name='test_attempts')
|
|
op.drop_table('test_attempts')
|
|
# ### end Alembic commands ###
|