# Generated by Django 3.2 on 2021-04-12 14:11

import datetime
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Author',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, verbose_name='UUID')),
                ('first_name', models.CharField(max_length=64, verbose_name='first name')),
                ('last_name', models.CharField(max_length=64, verbose_name='last name')),
                ('description', models.TextField(blank=True, verbose_name='description')),
                ('birth_date', models.DateField(default=datetime.date(2000, 1, 1), verbose_name='birth date')),
                ('registration_date', models.DateTimeField(auto_now_add=True, verbose_name='registration date')),
            ],
            options={
                'verbose_name': 'book author',
                'verbose_name_plural': 'book authors',
            },
        ),
        migrations.CreateModel(
            name='Genre',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, verbose_name='UUID')),
                ('code_name', models.CharField(max_length=64, unique=True, verbose_name='code name')),
                ('name', models.CharField(max_length=64, verbose_name='name')),
                ('description', models.TextField(blank=True, verbose_name='description')),
                ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='creation date')),
            ],
            options={
                'verbose_name': 'genre',
                'verbose_name_plural': 'genres',
            },
        ),
        migrations.CreateModel(
            name='Person',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role', models.PositiveSmallIntegerField(choices=[(0, 'employee'), (1, 'client')], db_index=True, default=0, verbose_name='role')),
                ('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, verbose_name='UUID')),
                ('first_name', models.CharField(max_length=64, verbose_name='first name')),
                ('last_name', models.CharField(max_length=64, verbose_name='last name')),
                ('birth_date', models.DateField(default=datetime.date(2000, 1, 1), verbose_name='birth date')),
                ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='creation date')),
                ('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='person', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'person',
                'verbose_name_plural': 'people',
            },
        ),
        migrations.CreateModel(
            name='Book',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, verbose_name='UUID')),
                ('isbn', models.CharField(max_length=64, verbose_name='ISBN')),
                ('name', models.CharField(max_length=128, verbose_name='name')),
                ('description', models.TextField(blank=True, verbose_name='description')),
                ('registration_date', models.DateTimeField(auto_now_add=True, verbose_name='creation date')),
                ('authors', models.ManyToManyField(related_name='books', to='library.Author', verbose_name='authors')),
                ('genre', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='books', to='library.genre', verbose_name='genre')),
            ],
            options={
                'verbose_name': 'book',
                'verbose_name_plural': 'books',
            },
        ),
        migrations.CreateModel(
            name='Loan',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, verbose_name='UUID')),
                ('date', models.DateTimeField(auto_now_add=True, verbose_name='date')),
                ('expected_return', models.DateTimeField(null=True, verbose_name='expected return date')),
                ('borrowed', models.NullBooleanField(default=True, verbose_name='borrowed')),
                ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='loans', to='library.book', verbose_name='book')),
                ('person', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='loans', to='library.person', verbose_name='person')),
            ],
            options={
                'verbose_name': 'book loan',
                'verbose_name_plural': 'book loans',
                'unique_together': {('book', 'borrowed')},
            },
        ),
    ]
