diff --git a/backend/docker-launch.sh b/backend/docker-launch.sh index 32e69bf..5e0c9aa 100644 --- a/backend/docker-launch.sh +++ b/backend/docker-launch.sh @@ -1,4 +1,5 @@ #!/bin/bash +alembic revision --autogenerate alembic upgrade head cd src || exit gunicorn main:app --workers 1 --worker-class uvicorn.workers.UvicornWorker --bind=0.0.0.0:"$BACK_APP_PORT" --timeout 300 \ No newline at end of file diff --git "a/backend/migrations/versions/2023_11_02_1707-ea5f600c8967_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.py" "b/backend/migrations/versions/2023_11_02_1707-ea5f600c8967_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.py" deleted file mode 100644 index cd26380..0000000 --- "a/backend/migrations/versions/2023_11_02_1707-ea5f600c8967_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.py" +++ /dev/null @@ -1,61 +0,0 @@ -"""Добавляет таблицы пользователей - -Revision ID: ea5f600c8967 -Revises: -Create Date: 2023-11-02 17:07:33.234938 - -""" -from typing import Sequence, Union - -import fastapi_users_db_sqlalchemy -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = 'ea5f600c8967' -down_revision: Union[str, None] = None -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_table('employees', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('name', sa.String(length=255), nullable=False), - sa.Column('last_name', sa.String(length=255), nullable=False), - sa.Column('email', sa.String(length=255), nullable=False), - sa.Column('hired_at', sa.Date(), server_default=sa.text('CURRENT_DATE'), nullable=False), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('email') - ) - op.create_table('tutors', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('name', sa.String(length=255), nullable=False), - sa.Column('last_name', sa.String(length=255), nullable=False), - sa.Column('email', sa.String(length=255), nullable=False), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('email') - ) - op.create_table('users', - sa.Column('role', sa.Enum(name='user_roles'), nullable=False), - sa.Column('id', fastapi_users_db_sqlalchemy.generics.GUID(), nullable=False), - sa.Column('email', sa.String(length=320), nullable=False), - sa.Column('hashed_password', sa.String(length=1024), nullable=False), - sa.Column('is_active', sa.Boolean(), nullable=False), - sa.Column('is_superuser', sa.Boolean(), nullable=False), - sa.Column('is_verified', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_users_email'), table_name='users') - op.drop_table('users') - op.drop_table('tutors') - op.drop_table('employees') - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_02_1709-6e79091c3fb1_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\276\321\201\320\275\320\276\320\262\321\203_\320\264\320\273\321\217_\320\267\320\260\320\264\320\260\320\275\320\270\320\271.py" "b/backend/migrations/versions/2023_11_02_1709-6e79091c3fb1_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\276\321\201\320\275\320\276\320\262\321\203_\320\264\320\273\321\217_\320\267\320\260\320\264\320\260\320\275\320\270\320\271.py" deleted file mode 100644 index f403ddb..0000000 --- "a/backend/migrations/versions/2023_11_02_1709-6e79091c3fb1_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\276\321\201\320\275\320\276\320\262\321\203_\320\264\320\273\321\217_\320\267\320\260\320\264\320\260\320\275\320\270\320\271.py" +++ /dev/null @@ -1,69 +0,0 @@ -"""Добавляет основу для заданий - -Revision ID: 6e79091c3fb1 -Revises: ea5f600c8967 -Create Date: 2023-11-02 17:09:18.002665 - -""" -from typing import Sequence, Union - -import sqlalchemy_utils -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = '6e79091c3fb1' -down_revision: Union[str, None] = 'ea5f600c8967' -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_table('levels', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('name', sa.String(length=255), nullable=False), - sa.Column('is_accomplished', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('maps', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('name', sa.String(length=255), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('modules', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('name', sa.String(length=255), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('tasks', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('is_accomplished', sa.Boolean(), nullable=False), - sa.Column('score_reward', sa.Integer(), nullable=False), - sa.Column('content', sa.Text(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('theory_blocks', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('theme', sa.String(), nullable=False), - sa.Column('content', sa.Text(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('theory_videos', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('url', sqlalchemy_utils.types.url.URLType(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('theory_videos') - op.drop_table('theory_blocks') - op.drop_table('tasks') - op.drop_table('modules') - op.drop_table('maps') - op.drop_table('levels') - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_02_1733-5aa9681ef1db_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\262\320\275\320\265\321\210\320\275\320\270\320\265_\320\272\320\273\321\216\321\207\320\270.py" "b/backend/migrations/versions/2023_11_02_1733-5aa9681ef1db_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\262\320\275\320\265\321\210\320\275\320\270\320\265_\320\272\320\273\321\216\321\207\320\270.py" deleted file mode 100644 index 314852b..0000000 --- "a/backend/migrations/versions/2023_11_02_1733-5aa9681ef1db_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\262\320\275\320\265\321\210\320\275\320\270\320\265_\320\272\320\273\321\216\321\207\320\270.py" +++ /dev/null @@ -1,48 +0,0 @@ -"""Добавляет внешние ключи - -Revision ID: 5aa9681ef1db -Revises: 6e79091c3fb1 -Create Date: 2023-11-02 17:33:20.640710 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = '5aa9681ef1db' -down_revision: Union[str, None] = '6e79091c3fb1' -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('employees', sa.Column('tutor_id', sa.UUID(), nullable=False)) - op.create_foreign_key(None, 'employees', 'tutors', ['tutor_id'], ['id']) - op.add_column('levels', sa.Column('module_id', sa.UUID(), nullable=False)) - op.create_foreign_key(None, 'levels', 'modules', ['module_id'], ['id']) - op.add_column('modules', sa.Column('previous_module_id', sa.UUID(), nullable=False)) - op.add_column('modules', sa.Column('next_module_id', sa.UUID(), nullable=False)) - op.create_foreign_key(None, 'modules', 'modules', ['next_module_id'], ['id']) - op.create_foreign_key(None, 'modules', 'modules', ['previous_module_id'], ['id']) - op.add_column('theory_videos', sa.Column('theory_id', sa.UUID(), nullable=False)) - op.create_foreign_key(None, 'theory_videos', 'theory_blocks', ['theory_id'], ['id']) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'theory_videos', type_='foreignkey') - op.drop_column('theory_videos', 'theory_id') - op.drop_constraint(None, 'modules', type_='foreignkey') - op.drop_constraint(None, 'modules', type_='foreignkey') - op.drop_column('modules', 'next_module_id') - op.drop_column('modules', 'previous_module_id') - op.drop_constraint(None, 'levels', type_='foreignkey') - op.drop_column('levels', 'module_id') - op.drop_constraint(None, 'employees', type_='foreignkey') - op.drop_column('employees', 'tutor_id') - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_15_1205-5bc05f78249a_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\320\262\320\276\320\277\321\200\320\276\321\201\320\276\320\262_\320\270_\320\276\321\202\320\262\320\265\321\202\320\276\320\262.py" "b/backend/migrations/versions/2023_11_15_1205-5bc05f78249a_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\320\262\320\276\320\277\321\200\320\276\321\201\320\276\320\262_\320\270_\320\276\321\202\320\262\320\265\321\202\320\276\320\262.py" deleted file mode 100644 index de15bce..0000000 --- "a/backend/migrations/versions/2023_11_15_1205-5bc05f78249a_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\320\262\320\276\320\277\321\200\320\276\321\201\320\276\320\262_\320\270_\320\276\321\202\320\262\320\265\321\202\320\276\320\262.py" +++ /dev/null @@ -1,60 +0,0 @@ -"""Добавляет таблицы вопросов и ответов - -Revision ID: 5bc05f78249a -Revises: 5aa9681ef1db -Create Date: 2023-11-15 12:05:18.429020 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = '5bc05f78249a' -down_revision: Union[str, None] = '5aa9681ef1db' -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_table('answers', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('question_id', sa.UUID(), nullable=False), - sa.Column('content', sa.String(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('questions', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('type', sa.Enum(name='question_types'), nullable=False), - sa.Column('question', sa.String(), nullable=False), - sa.Column('correct_answer_id', sa.UUID(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('task_employees', - sa.Column('task_id', sa.UUID(), nullable=False), - sa.Column('employee_id', sa.UUID(), nullable=False), - sa.Column('state', sa.Enum(name='task_states'), nullable=False), - sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ), - sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), - sa.PrimaryKeyConstraint('task_id', 'employee_id') - ) - op.add_column('tasks', sa.Column('type', sa.Enum(name='task_types'), nullable=False)) - op.add_column('tasks', sa.Column('requires_review', sa.Boolean(), nullable=False)) - op.drop_column('tasks', 'content') - op.drop_column('tasks', 'is_accomplished') - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('tasks', sa.Column('is_accomplished', sa.BOOLEAN(), autoincrement=False, nullable=False)) - op.add_column('tasks', sa.Column('content', sa.TEXT(), autoincrement=False, nullable=False)) - op.drop_column('tasks', 'requires_review') - op.drop_column('tasks', 'type') - op.drop_table('task_employees') - op.drop_table('questions') - op.drop_table('answers') - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_15_1521-24f2b6f0f8fd_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\320\264\320\273\321\217_\321\201\320\276\320\267\320\264\320\260\320\275\320\270\321\217_\321\203\321\200\320\276\320\262\320\275\320\265\320\271.py" "b/backend/migrations/versions/2023_11_15_1521-24f2b6f0f8fd_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\320\264\320\273\321\217_\321\201\320\276\320\267\320\264\320\260\320\275\320\270\321\217_\321\203\321\200\320\276\320\262\320\275\320\265\320\271.py" deleted file mode 100644 index 2a4c5f8..0000000 --- "a/backend/migrations/versions/2023_11_15_1521-24f2b6f0f8fd_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\320\264\320\273\321\217_\321\201\320\276\320\267\320\264\320\260\320\275\320\270\321\217_\321\203\321\200\320\276\320\262\320\275\320\265\320\271.py" +++ /dev/null @@ -1,55 +0,0 @@ -"""Добавляет таблицы для создания уровней - -Revision ID: 24f2b6f0f8fd -Revises: 5bc05f78249a -Create Date: 2023-11-15 15:21:40.114690 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = '24f2b6f0f8fd' -down_revision: Union[str, None] = '5bc05f78249a' -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_table('level_employees', - sa.Column('level_id', sa.UUID(), nullable=False), - sa.Column('employee_id', sa.UUID(), nullable=False), - sa.Column('state', sa.Enum(name='level_states'), nullable=False), - sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ), - sa.ForeignKeyConstraint(['level_id'], ['levels.id'], ), - sa.PrimaryKeyConstraint('level_id', 'employee_id') - ) - op.create_table('level_tasks', - sa.Column('level_id', sa.UUID(), nullable=False), - sa.Column('task_id', sa.UUID(), nullable=False), - sa.ForeignKeyConstraint(['level_id'], ['levels.id'], ), - sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), - sa.PrimaryKeyConstraint('level_id', 'task_id') - ) - op.create_table('level_theory_blocks', - sa.Column('level_id', sa.UUID(), nullable=False), - sa.Column('theory_id', sa.UUID(), nullable=False), - sa.ForeignKeyConstraint(['level_id'], ['levels.id'], ), - sa.ForeignKeyConstraint(['theory_id'], ['theory_blocks.id'], ), - sa.PrimaryKeyConstraint('level_id', 'theory_id') - ) - op.drop_column('levels', 'is_accomplished') - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('levels', sa.Column('is_accomplished', sa.BOOLEAN(), autoincrement=False, nullable=False)) - op.drop_table('level_theory_blocks') - op.drop_table('level_tasks') - op.drop_table('level_employees') - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_15_1530-9f5fe0dc8217_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\201\320\262\321\217\320\267\321\214_\320\274\320\265\320\266\320\264\321\203_\320\272\320\260\321\200\321\202\320\276\320\271_\320\270_\320\274\320\276\320\264\321\203\320\273\321\217\320\274\320\270.py" "b/backend/migrations/versions/2023_11_15_1530-9f5fe0dc8217_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\201\320\262\321\217\320\267\321\214_\320\274\320\265\320\266\320\264\321\203_\320\272\320\260\321\200\321\202\320\276\320\271_\320\270_\320\274\320\276\320\264\321\203\320\273\321\217\320\274\320\270.py" deleted file mode 100644 index 14365ba..0000000 --- "a/backend/migrations/versions/2023_11_15_1530-9f5fe0dc8217_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\201\320\262\321\217\320\267\321\214_\320\274\320\265\320\266\320\264\321\203_\320\272\320\260\321\200\321\202\320\276\320\271_\320\270_\320\274\320\276\320\264\321\203\320\273\321\217\320\274\320\270.py" +++ /dev/null @@ -1,40 +0,0 @@ -"""Добавляет связь между картой и модулями - -Revision ID: 9f5fe0dc8217 -Revises: 24f2b6f0f8fd -Create Date: 2023-11-15 15:30:50.105149 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = '9f5fe0dc8217' -down_revision: Union[str, None] = '24f2b6f0f8fd' -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('maps', sa.Column('title', sa.String(length=255), nullable=False)) - op.drop_column('maps', 'name') - op.add_column('modules', sa.Column('map_id', sa.UUID(), nullable=False)) - op.add_column('modules', sa.Column('title', sa.String(length=255), nullable=False)) - op.create_foreign_key(None, 'modules', 'maps', ['map_id'], ['id']) - op.drop_column('modules', 'name') - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('modules', sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False)) - op.drop_constraint(None, 'modules', type_='foreignkey') - op.drop_column('modules', 'title') - op.drop_column('modules', 'map_id') - op.add_column('maps', sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False)) - op.drop_column('maps', 'title') - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_15_1550-c22a2503060b_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\321\201_\320\264\320\276\320\272_\320\262\320\260\320\274\320\270_\320\262\321\213\320\277\320\276\320\273\320\275\320\265\320\275\320\270\321\217_.py" "b/backend/migrations/versions/2023_11_15_1550-c22a2503060b_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\321\201_\320\264\320\276\320\272_\320\262\320\260\320\274\320\270_\320\262\321\213\320\277\320\276\320\273\320\275\320\265\320\275\320\270\321\217_.py" deleted file mode 100644 index f4b3c31..0000000 --- "a/backend/migrations/versions/2023_11_15_1550-c22a2503060b_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\321\202\320\260\320\261\320\273\320\270\321\206\321\213_\321\201_\320\264\320\276\320\272_\320\262\320\260\320\274\320\270_\320\262\321\213\320\277\320\276\320\273\320\275\320\265\320\275\320\270\321\217_.py" +++ /dev/null @@ -1,49 +0,0 @@ -"""Добавляет таблицы с док-вами выполнения задания - -Revision ID: c22a2503060b -Revises: 9f5fe0dc8217 -Create Date: 2023-11-15 15:50:56.707333 - -""" -from typing import Sequence, Union - -import sqlalchemy_utils -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = 'c22a2503060b' -down_revision: Union[str, None] = '9f5fe0dc8217' -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_table('image_proofs', - sa.Column('proof_id', sa.UUID(), nullable=False), - sa.Column('image_url', sqlalchemy_utils.types.url.URLType(), nullable=False), - sa.PrimaryKeyConstraint('proof_id', 'image_url') - ) - op.create_table('proofs', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('task_id', sa.UUID(), nullable=False), - sa.Column('employee_id', sa.UUID(), nullable=False), - sa.Column('message', sa.Text(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('video_proofs', - sa.Column('proof_id', sa.UUID(), nullable=False), - sa.Column('video_url', sqlalchemy_utils.types.url.URLType(), nullable=False), - sa.PrimaryKeyConstraint('proof_id', 'video_url') - ) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('video_proofs') - op.drop_table('proofs') - op.drop_table('image_proofs') - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_15_1946-1acf032a74df_\321\203\320\264\320\260\320\273\321\217\320\265\321\202_\320\277\320\276\320\273\321\217_\320\277\320\276\321\207\321\202\321\213_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\277\320\276\320\273\320\265_.py" "b/backend/migrations/versions/2023_11_15_1946-1acf032a74df_\321\203\320\264\320\260\320\273\321\217\320\265\321\202_\320\277\320\276\320\273\321\217_\320\277\320\276\321\207\321\202\321\213_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\277\320\276\320\273\320\265_.py" deleted file mode 100644 index 50f43a2..0000000 --- "a/backend/migrations/versions/2023_11_15_1946-1acf032a74df_\321\203\320\264\320\260\320\273\321\217\320\265\321\202_\320\277\320\276\320\273\321\217_\320\277\320\276\321\207\321\202\321\213_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\277\320\276\320\273\320\265_.py" +++ /dev/null @@ -1,42 +0,0 @@ -"""удаляет поля почты, добавляет поле юзернейма - -Revision ID: 1acf032a74df -Revises: c22a2503060b -Create Date: 2023-11-15 19:46:04.819280 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = '1acf032a74df' -down_revision: Union[str, None] = 'c22a2503060b' -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_constraint('employees_email_key', 'employees', type_='unique') - op.drop_column('employees', 'email') - op.drop_constraint('tutors_email_key', 'tutors', type_='unique') - op.drop_column('tutors', 'email') - op.add_column('users', sa.Column('username', sa.String(), nullable=False)) - op.add_column('users', sa.Column('registered_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False)) - op.create_unique_constraint(None, 'users', ['username']) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'users', type_='unique') - op.drop_column('users', 'registered_at') - op.drop_column('users', 'username') - op.add_column('tutors', sa.Column('email', sa.VARCHAR(length=255), autoincrement=False, nullable=False)) - op.create_unique_constraint('tutors_email_key', 'tutors', ['email']) - op.add_column('employees', sa.Column('email', sa.VARCHAR(length=255), autoincrement=False, nullable=False)) - op.create_unique_constraint('employees_email_key', 'employees', ['email']) - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_16_1501-1e7465593407_\320\270\320\267\320\274\320\265\320\275\321\217\320\265\321\202_\320\276\320\277\321\200\320\265\320\264\320\265\320\273\320\265\320\275\320\270\320\265_\320\277\320\265\321\200\320\265\321\207\320\270\321\201\320\273\320\265\320\275\320\270\320\271_.py" "b/backend/migrations/versions/2023_11_16_1501-1e7465593407_\320\270\320\267\320\274\320\265\320\275\321\217\320\265\321\202_\320\276\320\277\321\200\320\265\320\264\320\265\320\273\320\265\320\275\320\270\320\265_\320\277\320\265\321\200\320\265\321\207\320\270\321\201\320\273\320\265\320\275\320\270\320\271_.py" deleted file mode 100644 index 1283192..0000000 --- "a/backend/migrations/versions/2023_11_16_1501-1e7465593407_\320\270\320\267\320\274\320\265\320\275\321\217\320\265\321\202_\320\276\320\277\321\200\320\265\320\264\320\265\320\273\320\265\320\275\320\270\320\265_\320\277\320\265\321\200\320\265\321\207\320\270\321\201\320\273\320\265\320\275\320\270\320\271_.py" +++ /dev/null @@ -1,56 +0,0 @@ -"""Изменяет определение перечислений, временно удаляет роль пользователя - -Revision ID: 1e7465593407 -Revises: 1acf032a74df -Create Date: 2023-11-16 15:01:09.555491 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '1e7465593407' -down_revision: Union[str, None] = '1acf032a74df' -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_column('users', 'role') - sa.Enum('employee', 'tutor', 'hr', name='user_roles').drop(op.get_bind()) - op.sync_enum_values('public', 'level_states', ['NotViewed', 'Viewed', 'Completed'], - [('level_employees', 'state')], - enum_values_to_rename=[]) - op.sync_enum_values('public', 'task_types', ['Test'], - [('tasks', 'type')], - enum_values_to_rename=[]) - op.sync_enum_values('public', 'task_states', ['NotViewed', 'Viewed', 'Submitted', 'Finished'], - [('task_employees', 'state')], - enum_values_to_rename=[]) - op.sync_enum_values('public', 'question_types', ['SingleChoice', 'MultipleChoice'], - [('questions', 'type')], - enum_values_to_rename=[]) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.sync_enum_values('public', 'question_types', [], - [('questions', 'type')], - enum_values_to_rename=[]) - op.sync_enum_values('public', 'task_states', [], - [('task_employees', 'state')], - enum_values_to_rename=[]) - op.sync_enum_values('public', 'task_types', [], - [('tasks', 'type')], - enum_values_to_rename=[]) - op.sync_enum_values('public', 'level_states', [], - [('level_employees', 'state')], - enum_values_to_rename=[]) - sa.Enum('employee', 'tutor', 'hr', name='user_roles').create(op.get_bind()) - op.add_column('users', sa.Column('role', postgresql.ENUM('employee', 'tutor', 'hr', name='user_roles', create_type=False), autoincrement=False, nullable=False)) - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_16_1502-9a94a7ad2790_\320\262\320\276\320\267\320\262\321\200\320\260\321\211\320\260\320\265\321\202_\321\200\320\276\320\273\320\270_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.py" "b/backend/migrations/versions/2023_11_16_1502-9a94a7ad2790_\320\262\320\276\320\267\320\262\321\200\320\260\321\211\320\260\320\265\321\202_\321\200\320\276\320\273\320\270_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.py" deleted file mode 100644 index 77106a0..0000000 --- "a/backend/migrations/versions/2023_11_16_1502-9a94a7ad2790_\320\262\320\276\320\267\320\262\321\200\320\260\321\211\320\260\320\265\321\202_\321\200\320\276\320\273\320\270_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.py" +++ /dev/null @@ -1,32 +0,0 @@ -"""возвращает роли пользователя - -Revision ID: 9a94a7ad2790 -Revises: 1e7465593407 -Create Date: 2023-11-16 15:02:38.538132 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '9a94a7ad2790' -down_revision: Union[str, None] = '1e7465593407' -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! ### - sa.Enum('Employee', 'Tutor', 'HR', name='user_roles').create(op.get_bind()) - op.add_column('users', sa.Column('role', postgresql.ENUM('Employee', 'Tutor', 'HR', name='user_roles', create_type=False), nullable=False)) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'role') - sa.Enum('Employee', 'Tutor', 'HR', name='user_roles').drop(op.get_bind()) - # ### end Alembic commands ### diff --git "a/backend/migrations/versions/2023_11_17_1106-b71a5f16b60e_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\276\321\201\320\275\320\276\320\262\320\275\321\213\320\265_\321\202\320\260\320\261\320\273\320\270\321\206\321\213.py" "b/backend/migrations/versions/2023_11_17_1106-b71a5f16b60e_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\276\321\201\320\275\320\276\320\262\320\275\321\213\320\265_\321\202\320\260\320\261\320\273\320\270\321\206\321\213.py" new file mode 100644 index 0000000..a828626 --- /dev/null +++ "b/backend/migrations/versions/2023_11_17_1106-b71a5f16b60e_\320\264\320\276\320\261\320\260\320\262\320\273\321\217\320\265\321\202_\320\276\321\201\320\275\320\276\320\262\320\275\321\213\320\265_\321\202\320\260\320\261\320\273\320\270\321\206\321\213.py" @@ -0,0 +1,191 @@ +"""Добавляет основные таблицы + +Revision ID: b71a5f16b60e +Revises: +Create Date: 2023-11-17 11:06:28.938025 + +""" +from typing import Sequence, Union + +import fastapi_users_db_sqlalchemy +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision: str = 'b71a5f16b60e' +down_revision: Union[str, None] = None +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! ### + sa.Enum('Employee', 'Tutor', 'HR', name='user_roles').create(op.get_bind()) + sa.Enum('SingleChoice', 'MultipleChoice', name='question_types').create(op.get_bind()) + sa.Enum('NotViewed', 'Viewed', 'Submitted', 'Finished', name='task_states').create(op.get_bind()) + sa.Enum('Test', name='task_types').create(op.get_bind()) + sa.Enum('NotViewed', 'Viewed', 'Completed', name='level_states').create(op.get_bind()) + op.create_table('answers', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('question_id', sa.UUID(), nullable=False), + sa.Column('content', sa.String(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('image_proofs', + sa.Column('proof_id', sa.UUID(), nullable=False), + sa.Column('image_url', sqlalchemy_utils.types.url.URLType(), nullable=False), + sa.PrimaryKeyConstraint('proof_id', 'image_url') + ) + op.create_table('maps', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('title', sa.String(length=255), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('proofs', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('task_id', sa.UUID(), nullable=False), + sa.Column('employee_id', sa.UUID(), nullable=False), + sa.Column('message', sa.Text(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('questions', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('type', postgresql.ENUM('SingleChoice', 'MultipleChoice', name='question_types', create_type=False), nullable=False), + sa.Column('question', sa.String(), nullable=False), + sa.Column('correct_answer_id', sa.UUID(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('tasks', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('type', postgresql.ENUM('Test', name='task_types', create_type=False), nullable=False), + sa.Column('requires_review', sa.Boolean(), nullable=False), + sa.Column('score_reward', sa.Integer(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('theory_blocks', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('theme', sa.String(), nullable=False), + sa.Column('content', sa.Text(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('tutors', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('name', sa.String(length=255), nullable=False), + sa.Column('last_name', sa.String(length=255), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('users', + sa.Column('username', sa.String(), nullable=False), + sa.Column('role', postgresql.ENUM('Employee', 'Tutor', 'HR', name='user_roles', create_type=False), nullable=False), + sa.Column('registered_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), + sa.Column('id', fastapi_users_db_sqlalchemy.generics.GUID(), nullable=False), + sa.Column('email', sa.String(length=320), nullable=False), + sa.Column('hashed_password', sa.String(length=1024), nullable=False), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('is_superuser', sa.Boolean(), nullable=False), + sa.Column('is_verified', sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('username') + ) + op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) + op.create_table('video_proofs', + sa.Column('proof_id', sa.UUID(), nullable=False), + sa.Column('video_url', sqlalchemy_utils.types.url.URLType(), nullable=False), + sa.PrimaryKeyConstraint('proof_id', 'video_url') + ) + op.create_table('employees', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('tutor_id', sa.UUID(), nullable=False), + sa.Column('name', sa.String(length=255), nullable=False), + sa.Column('last_name', sa.String(length=255), nullable=False), + sa.Column('hired_at', sa.Date(), server_default=sa.text('CURRENT_DATE'), nullable=False), + sa.ForeignKeyConstraint(['tutor_id'], ['tutors.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('modules', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('previous_module_id', sa.UUID(), nullable=False), + sa.Column('next_module_id', sa.UUID(), nullable=False), + sa.Column('map_id', sa.UUID(), nullable=False), + sa.Column('title', sa.String(length=255), nullable=False), + sa.ForeignKeyConstraint(['map_id'], ['maps.id'], ), + sa.ForeignKeyConstraint(['next_module_id'], ['modules.id'], ), + sa.ForeignKeyConstraint(['previous_module_id'], ['modules.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('theory_videos', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('theory_id', sa.UUID(), nullable=False), + sa.Column('url', sqlalchemy_utils.types.url.URLType(), nullable=False), + sa.ForeignKeyConstraint(['theory_id'], ['theory_blocks.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('levels', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('module_id', sa.UUID(), nullable=False), + sa.Column('name', sa.String(length=255), nullable=False), + sa.ForeignKeyConstraint(['module_id'], ['modules.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('task_employees', + sa.Column('task_id', sa.UUID(), nullable=False), + sa.Column('employee_id', sa.UUID(), nullable=False), + sa.Column('state', postgresql.ENUM('NotViewed', 'Viewed', 'Submitted', 'Finished', name='task_states', create_type=False), nullable=False), + sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ), + sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), + sa.PrimaryKeyConstraint('task_id', 'employee_id') + ) + op.create_table('level_employees', + sa.Column('level_id', sa.UUID(), nullable=False), + sa.Column('employee_id', sa.UUID(), nullable=False), + sa.Column('state', postgresql.ENUM('NotViewed', 'Viewed', 'Completed', name='level_states', create_type=False), nullable=False), + sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ), + sa.ForeignKeyConstraint(['level_id'], ['levels.id'], ), + sa.PrimaryKeyConstraint('level_id', 'employee_id') + ) + op.create_table('level_tasks', + sa.Column('level_id', sa.UUID(), nullable=False), + sa.Column('task_id', sa.UUID(), nullable=False), + sa.ForeignKeyConstraint(['level_id'], ['levels.id'], ), + sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), + sa.PrimaryKeyConstraint('level_id', 'task_id') + ) + op.create_table('level_theory_blocks', + sa.Column('level_id', sa.UUID(), nullable=False), + sa.Column('theory_id', sa.UUID(), nullable=False), + sa.ForeignKeyConstraint(['level_id'], ['levels.id'], ), + sa.ForeignKeyConstraint(['theory_id'], ['theory_blocks.id'], ), + sa.PrimaryKeyConstraint('level_id', 'theory_id') + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('level_theory_blocks') + op.drop_table('level_tasks') + op.drop_table('level_employees') + op.drop_table('task_employees') + op.drop_table('levels') + op.drop_table('theory_videos') + op.drop_table('modules') + op.drop_table('employees') + op.drop_table('video_proofs') + op.drop_index(op.f('ix_users_email'), table_name='users') + op.drop_table('users') + op.drop_table('tutors') + op.drop_table('theory_blocks') + op.drop_table('tasks') + op.drop_table('questions') + op.drop_table('proofs') + op.drop_table('maps') + op.drop_table('image_proofs') + op.drop_table('answers') + sa.Enum('NotViewed', 'Viewed', 'Completed', name='level_states').drop(op.get_bind()) + sa.Enum('Test', name='task_types').drop(op.get_bind()) + sa.Enum('NotViewed', 'Viewed', 'Submitted', 'Finished', name='task_states').drop(op.get_bind()) + sa.Enum('SingleChoice', 'MultipleChoice', name='question_types').drop(op.get_bind()) + sa.Enum('Employee', 'Tutor', 'HR', name='user_roles').drop(op.get_bind()) + # ### end Alembic commands ###