Skip to content

Commit

Permalink
Обновляет миграции
Browse files Browse the repository at this point in the history
  • Loading branch information
codEnjoyer committed Nov 19, 2023
1 parent cbcb7d7 commit 032f9e3
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""добавляет связь между задачей и ответами
Revision ID: 43a526a12009
Revises: 5bbffa09568b
Create Date: 2023-11-19 10:35:20.123826
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '43a526a12009'
down_revision: Union[str, None] = '5bbffa09568b'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('questions', sa.Column('task_id', sa.UUID(), nullable=True))
op.create_foreign_key(None, 'questions', 'tasks', ['task_id'], ['id'])
op.add_column('tasks', sa.Column('level_id', sa.UUID(), nullable=True))
op.create_foreign_key(None, 'tasks', 'levels', ['level_id'], ['id'])
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'tasks', type_='foreignkey')
op.drop_column('tasks', 'level_id')
op.drop_constraint(None, 'questions', type_='foreignkey')
op.drop_column('questions', 'task_id')
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""добавляет связь между вопросами и ответами
Revision ID: e21d5fb84a66
Revises: 43a526a12009
Create Date: 2023-11-19 10:37:12.398132
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'e21d5fb84a66'
down_revision: Union[str, None] = '43a526a12009'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_foreign_key(None, 'answers', 'questions', ['question_id'], ['id'])
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'answers', type_='foreignkey')
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""временно удаляет таблицу с видео теории
Revision ID: e8496d8a36fc
Revises: e21d5fb84a66
Create Date: 2023-11-19 10:48:35.457329
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'e8496d8a36fc'
down_revision: Union[str, None] = 'e21d5fb84a66'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('theory_videos')
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('theory_videos',
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
sa.Column('theory_id', sa.UUID(), autoincrement=False, nullable=False),
sa.Column('url', sa.TEXT(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['theory_id'], ['theory_blocks.id'], name='theory_videos_theory_id_fkey'),
sa.PrimaryKeyConstraint('id', name='theory_videos_pkey')
)
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""модуль и уровни обязательно привязаны к родителю
Revision ID: 4e3cf7a2acb2
Revises: e8496d8a36fc
Create Date: 2023-11-19 21:46:34.041826
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '4e3cf7a2acb2'
down_revision: Union[str, None] = 'e8496d8a36fc'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('levels', 'module_id',
existing_type=sa.UUID(),
nullable=False)
op.alter_column('modules', 'map_id',
existing_type=sa.UUID(),
nullable=False)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('modules', 'map_id',
existing_type=sa.UUID(),
nullable=True)
op.alter_column('levels', 'module_id',
existing_type=sa.UUID(),
nullable=True)
# ### end Alembic commands ###

0 comments on commit 032f9e3

Please sign in to comment.