"""Add rows

Revision ID: bef3d37b0c37
Revises: f86708f72a8e
Create Date: 2021-06-03 00:37:09.213351

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "bef3d37b0c37"
down_revision = "f86708f72a8e"
branch_labels = None
depends_on = None
from datetime import datetime

from alembic import op
from sqlalchemy import Boolean, Date, DateTime, Integer, String
from sqlalchemy.sql import column, table


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###

    students_table = table(
        "student",
        column("id", Integer),
        column("first_name", String),
        column("last_name", String),
    )

    op.bulk_insert(
        students_table,
        [
            {"id": 1, "first_name": "Roman", "last_name": "Petrov"},
            {"id": 2, "first_name": "Lev", "last_name": "Sokolov"},
        ],
    )

    teachers_table = table(
        "teacher",
        column("id", Integer),
        column("first_name", String),
        column("last_name", String),
    )

    op.bulk_insert(
        teachers_table,
        [
            {"id": 1, "first_name": "Daniil", "last_name": "Shadrin"},
            {"id": 2, "first_name": "Aleksandr", "last_name": "Smetanin"},
        ],
    )

    homeworks_table = table(
        "homework",
        column("id", Integer),
        column("text", String),
        column("created", DateTime),
        column("deadline", Integer),
        column("teacher_id", Integer),
    )

    op.bulk_insert(
        homeworks_table,
        [
            {
                "id": 1,
                "text": "Learn OOP",
                "created": datetime.now(),
                "deadline": 1,
                "teacher_id": 1,
            },
            {
                "id": 2,
                "text": "Read docs",
                "created": datetime.now(),
                "deadline": 5,
                "teacher_id": 1,
            },
        ],
    )
    homework_results_table = table(
        "homework_result",
        column("id", Integer),
        column("homework_id", Integer),
        column("student_id", Integer),
        column("solution", String),
        column("created", DateTime),
        column("accepted", Boolean),
    )

    op.bulk_insert(
        homework_results_table,
        [
            {
                "id": 1,
                "homework_id": 1,
                "student_id": 2,
                "solution": "I have done this hw",
                "created": datetime.now(),
                "accepted": 0,
            },
            {
                "id": 2,
                "homework_id": 2,
                "student_id": 2,
                "solution": "I have done this hw too",
                "created": datetime.now(),
                "accepted": 0,
            },
        ],
    )

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    ...
    # ### end Alembic commands ###
