"""0001 инициализация Revision ID: 6241a16321b4 Revises: Create Date: 2025-11-27 13:33:22.506743 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision: str = '6241a16321b4' down_revision: Union[str, Sequence[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('courses', sa.Column('title', sa.String(length=250), nullable=False), sa.Column('description', sa.String(length=1000), nullable=True), sa.Column('photo_filename', sa.String(), nullable=False), sa.Column('photo_path', sa.String(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.PrimaryKeyConstraint('id'), schema='public' ) op.create_table('roles', sa.Column('title', sa.String(length=150), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('title'), schema='public' ) op.create_table('statuses', sa.Column('title', sa.String(length=250), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('title'), schema='public' ) op.create_table('users', sa.Column('first_name', sa.String(length=250), nullable=False), sa.Column('last_name', sa.String(length=250), nullable=False), sa.Column('patronymic', sa.String(length=250), nullable=True), sa.Column('login', sa.String(length=250), nullable=False), sa.Column('password_hash', sa.String(), nullable=False), sa.Column('email', sa.String(length=250), nullable=True), sa.Column('birthdate', sa.Date(), nullable=False), sa.Column('reg_date', sa.Date(), nullable=False), sa.Column('last_visit', sa.DateTime(), nullable=True), sa.Column('photo_filename', sa.String(length=250), nullable=True), sa.Column('photo_path', sa.String(), nullable=True), sa.Column('status_id', sa.Integer(), nullable=False), sa.Column('role_id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['role_id'], ['public.roles.id'], ), sa.ForeignKeyConstraint(['status_id'], ['public.statuses.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('login'), schema='public' ) op.create_table('course_teachers', sa.Column('course_id', sa.Integer(), nullable=False), sa.Column('teacher_id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['course_id'], ['public.courses.id'], ), sa.ForeignKeyConstraint(['teacher_id'], ['public.users.id'], ), sa.PrimaryKeyConstraint('id'), schema='public' ) op.create_table('enrollments', sa.Column('enrollment_date', sa.DateTime(), nullable=False), sa.Column('course_id', sa.Integer(), nullable=False), sa.Column('student_id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['course_id'], ['public.courses.id'], ), sa.ForeignKeyConstraint(['student_id'], ['public.users.id'], ), sa.PrimaryKeyConstraint('id'), schema='public' ) op.create_table('lessons', sa.Column('title', sa.String(length=250), nullable=False), sa.Column('description', sa.String(), nullable=True), sa.Column('text', sa.String(), nullable=True), sa.Column('number', sa.Integer(), nullable=False), sa.Column('course_id', sa.Integer(), nullable=False), sa.Column('creator_id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['course_id'], ['public.courses.id'], ), sa.ForeignKeyConstraint(['creator_id'], ['public.users.id'], ), sa.PrimaryKeyConstraint('id'), schema='public' ) op.create_table('tasks', sa.Column('title', sa.String(length=250), nullable=False), sa.Column('description', sa.String(), nullable=True), sa.Column('text', sa.String(), nullable=True), sa.Column('number', sa.Integer(), nullable=False), sa.Column('course_id', sa.Integer(), nullable=False), sa.Column('creator_id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['course_id'], ['public.courses.id'], ), sa.ForeignKeyConstraint(['creator_id'], ['public.users.id'], ), sa.PrimaryKeyConstraint('id'), schema='public' ) op.create_table('lesson_files', sa.Column('lesson_id', sa.Integer(), nullable=False), sa.Column('filename', sa.String(), nullable=False), sa.Column('file_path', sa.String(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['lesson_id'], ['public.lessons.id'], ), sa.PrimaryKeyConstraint('id'), schema='public' ) op.create_table('solutions', sa.Column('answer_text', sa.String(), nullable=True), sa.Column('assessment_text', sa.String(length=50), nullable=True), sa.Column('assessment_autor_id', sa.Integer(), nullable=True), sa.Column('task_id', sa.Integer(), nullable=False), sa.Column('student_id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['assessment_autor_id'], ['public.users.id'], ), sa.ForeignKeyConstraint(['student_id'], ['public.users.id'], ), sa.ForeignKeyConstraint(['task_id'], ['public.tasks.id'], ), sa.PrimaryKeyConstraint('id'), schema='public' ) op.create_table('task_files', sa.Column('task_id', sa.Integer(), nullable=False), sa.Column('filename', sa.String(), nullable=False), sa.Column('file_path', sa.String(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['task_id'], ['public.tasks.id'], ), sa.PrimaryKeyConstraint('id'), schema='public' ) op.create_table('solution_files', sa.Column('solution_id', sa.Integer(), nullable=False), sa.Column('filename', sa.String(), nullable=False), sa.Column('file_path', sa.String(), nullable=False), sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), sa.ForeignKeyConstraint(['solution_id'], ['public.solutions.id'], ), sa.PrimaryKeyConstraint('id'), schema='public' ) # ### end Alembic commands ### def downgrade() -> None: """Downgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.drop_table('solution_files', schema='public') op.drop_table('task_files', schema='public') op.drop_table('solutions', schema='public') op.drop_table('lesson_files', schema='public') op.drop_table('tasks', schema='public') op.drop_table('lessons', schema='public') op.drop_table('enrollments', schema='public') op.drop_table('course_teachers', schema='public') op.drop_table('users', schema='public') op.drop_table('statuses', schema='public') op.drop_table('roles', schema='public') op.drop_table('courses', schema='public') # ### end Alembic commands ###