# Generated by Django 3.1.4 on 2020-12-27 20:59
from datetime import datetime, timedelta

from django.db import migrations


def create_tables_records(apps, schema_editor):
    Homework = apps.get_model("school", "Homework")
    HomeworkResult = apps.get_model("school", "HomeworkResult")
    Student = apps.get_model("school", "Student")
    Teacher = apps.get_model("school", "Teacher")

    student_1 = Student(first_name="Tim", last_name="Nekuk", age=26)
    homework_1 = Homework(
        text="Final HW!", deadline=timedelta(days=3), created=datetime.now()
    )
    hw_1_result = HomeworkResult(
        homework=homework_1,
        author=student_1,
        solution="Hope fine",
        created=datetime.now(),
    )
    teacher_1 = Teacher(first_name="Bob", last_name="Kelso", homework_done=hw_1_result)

    student_1.save()
    homework_1.save()
    hw_1_result.save()
    teacher_1.save()


class Migration(migrations.Migration):

    dependencies = [
        ("school", "0001_initial"),
    ]

    operations = [
        migrations.RunPython(create_tables_records),
    ]
