# Generated by Django 2.2.11 on 2020-04-22 07:30

from django.conf import settings
import django.contrib.postgres.fields
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import simple_history.models
import varda.models
import varda.validators


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('varda', '0018_auto_20200408_1413'),
    ]

    operations = [
        migrations.AddField(
            model_name='z2_koodisto',
            name='lahdejarjestelma_koodit',
            field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=2), default=varda.models.lahdejarjestelma_koodit_default, size=None),
        ),
        migrations.CreateModel(
            name='Tyontekija',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('lahdejarjestelma', models.CharField(max_length=2, validators=[varda.validators.validate_lahdejarjestelma_koodi])),
                ('tunniste', models.CharField(blank=True, max_length=120, null=True, validators=[varda.validators.validate_tunniste])),
                ('luonti_pvm', models.DateTimeField(auto_now_add=True)),
                ('muutos_pvm', models.DateTimeField(auto_now=True)),
                ('changed_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='tyontekijat', to=settings.AUTH_USER_MODEL)),
                ('henkilo', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='tyontekijat', to='varda.Henkilo')),
                ('vakajarjestaja', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='tyontekijat', to='varda.VakaJarjestaja')),
            ],
            options={
                'verbose_name_plural': 'tyontekijat',
            },
        ),
        migrations.CreateModel(
            name='HistoricalTyontekija',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('lahdejarjestelma', models.CharField(max_length=2, validators=[varda.validators.validate_lahdejarjestelma_koodi])),
                ('tunniste', models.CharField(blank=True, max_length=120, null=True, validators=[varda.validators.validate_tunniste])),
                ('luonti_pvm', models.DateTimeField(blank=True, editable=False)),
                ('muutos_pvm', models.DateTimeField(blank=True, editable=False)),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('changed_by', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('henkilo', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='varda.Henkilo')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('vakajarjestaja', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='varda.VakaJarjestaja')),
            ],
            options={
                'verbose_name': 'historical tyontekija',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='BatchError',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.TextField(choices=[('LAPSI_HUOLTAJUUSSUHDE_UPDATE', 'LAPSI_HUOLTAJUUSSUHDE_UPDATE')])),
                ('retry_time', models.DateTimeField(default=django.utils.timezone.now)),
                ('retry_count', models.IntegerField(default=0)),
                ('error_message', models.TextField()),
                ('henkilo', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='batcherrors', to='varda.Henkilo')),
            ],
            options={
                'verbose_name_plural': 'batcherrors',
            },
        ),
    ]
