-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавляет миграции, создающие основные таблицы
- Loading branch information
1 parent
3164b94
commit baab615
Showing
3 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
backend/migrations/versions/2023_11_02_1707-ea5f600c8967_добавляет_таблицы_пользователей.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"""Добавляет таблицы пользователей | ||
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 ### |
69 changes: 69 additions & 0 deletions
69
backend/migrations/versions/2023_11_02_1709-6e79091c3fb1_добавляет_основу_для_заданий.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""Добавляет основу для заданий | ||
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 ### |