business-card-site/API/app/database/migrations/versions/d53be3a35511_0001_инициализация.py

170 lines
8.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""0001_инициализация
Revision ID: d53be3a35511
Revises:
Create Date: 2025-04-13 13:16:29.461322
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision: str = 'd53be3a35511'
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:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('contest_statuses',
sa.Column('title', sa.VARCHAR(length=150), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title')
)
op.create_table('projects',
sa.Column('description', sa.VARCHAR(length=150), nullable=True),
sa.Column('repository_url', sa.String(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('roles',
sa.Column('title', mysql.VARCHAR(length=150), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title')
)
op.create_table('teams',
sa.Column('title', sa.VARCHAR(length=150), nullable=False),
sa.Column('description', sa.VARCHAR(length=150), nullable=True),
sa.Column('logo', sa.String(), nullable=True),
sa.Column('git_url', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('contests',
sa.Column('title', sa.VARCHAR(length=150), nullable=False),
sa.Column('description', sa.String(), nullable=True),
sa.Column('web_url', sa.String(), nullable=False),
sa.Column('photo', sa.String(), nullable=True),
sa.Column('results', sa.String(), nullable=True),
sa.Column('is_win', sa.Boolean(), nullable=True),
sa.Column('project_id', sa.Integer(), nullable=False),
sa.Column('status_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
sa.ForeignKeyConstraint(['status_id'], ['contest_statuses.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title')
)
op.create_table('profiles',
sa.Column('first_name', sa.VARCHAR(length=150), nullable=False),
sa.Column('last_name', sa.VARCHAR(length=150), nullable=False),
sa.Column('patronymic', sa.VARCHAR(length=150), nullable=True),
sa.Column('birthday', sa.Date(), nullable=False),
sa.Column('email', sa.VARCHAR(length=150), nullable=True),
sa.Column('phone', sa.VARCHAR(length=28), nullable=True),
sa.Column('role_id', sa.Integer(), nullable=False),
sa.Column('team_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('project_files',
sa.Column('file_path', sa.String(), nullable=False),
sa.Column('project_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('file_path')
)
op.create_table('contest_carousel_photos',
sa.Column('file_path', sa.String(), nullable=False),
sa.Column('number', sa.Integer(), nullable=False),
sa.Column('contest_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['contest_id'], ['contests.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('contest_files',
sa.Column('file_path', sa.String(), nullable=False),
sa.Column('contest_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['contest_id'], ['contests.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('profile_photos',
sa.Column('file_path', sa.String(), nullable=False),
sa.Column('profile_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['profile_id'], ['profiles.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('project_members',
sa.Column('description', sa.String(), nullable=True),
sa.Column('project_id', sa.Integer(), nullable=False),
sa.Column('profile_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['profile_id'], ['profiles.id'], ),
sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('users',
sa.Column('login', sa.VARCHAR(length=150), nullable=False),
sa.Column('password', sa.VARCHAR(length=150), nullable=False),
sa.Column('profile_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['profile_id'], ['profiles.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('login')
)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('users')
op.drop_table('project_members')
op.drop_table('profile_photos')
op.drop_table('contest_files')
op.drop_table('contest_carousel_photos')
op.drop_table('project_files')
op.drop_table('profiles')
op.drop_table('contests')
op.drop_table('teams')
op.drop_table('roles')
op.drop_table('projects')
op.drop_table('contest_statuses')
# ### end Alembic commands ###