mirror of
https://github.com/koloideal/Quizzi.git
synced 2026-06-10 18:35:28 +03:00
44 lines
1.9 KiB
Python
44 lines
1.9 KiB
Python
"""add_indexes_and_fk
|
|
|
|
Revision ID: ca107b03ddf8
|
|
Revises: 40f5317720a4
|
|
Create Date: 2026-01-04 15:32:14.881408
|
|
|
|
"""
|
|
from collections.abc import Sequence
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision: str = 'ca107b03ddf8'
|
|
down_revision: str | None = '40f5317720a4'
|
|
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_index(op.f('ix_options_question_id'), 'options', ['question_id'], unique=False)
|
|
op.create_index(op.f('ix_questions_test_id'), 'questions', ['test_id'], unique=False)
|
|
op.create_index(op.f('ix_test_attempts_test_id'), 'test_attempts', ['test_id'], unique=False)
|
|
op.create_foreign_key(None, 'test_attempts', 'users', ['user_id'], ['id'])
|
|
op.create_index(op.f('ix_user_answers_attempt_id'), 'user_answers', ['attempt_id'], unique=False)
|
|
op.create_index(op.f('ix_user_answers_question_id'), 'user_answers', ['question_id'], unique=False)
|
|
op.create_index(op.f('ix_users_group'), 'users', ['group'], unique=False)
|
|
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_users_username'), table_name='users')
|
|
op.drop_index(op.f('ix_users_group'), table_name='users')
|
|
op.drop_index(op.f('ix_user_answers_question_id'), table_name='user_answers')
|
|
op.drop_index(op.f('ix_user_answers_attempt_id'), table_name='user_answers')
|
|
op.drop_constraint(None, 'test_attempts', type_='foreignkey')
|
|
op.drop_index(op.f('ix_test_attempts_test_id'), table_name='test_attempts')
|
|
op.drop_index(op.f('ix_questions_test_id'), table_name='questions')
|
|
op.drop_index(op.f('ix_options_question_id'), table_name='options')
|
|
# ### end Alembic commands ###
|