# Generated by Django 3.1.6 on 2021-06-22 05:34

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    operations = [
        migrations.CreateModel(
            name='Action',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('consumer_pk', models.PositiveIntegerField(blank=True, null=True, verbose_name='Consumer PK')),
                ('action_type', models.PositiveSmallIntegerField(choices=[(0, 'Созданный объект'), (1, 'Отредактированный объект'), (2, 'Удаленный объект'), (3, 'отмена'), (4, 'Переименованный объект'), (5, 'Перемещено в корзину'), (6, 'Восстановлен из корзины')], verbose_name='Тип действия')),
                ('ip', models.CharField(max_length=15, null=True, verbose_name='IP адрес')),
                ('show_in_timeline', models.BooleanField(default=True, verbose_name='Показать на временной шкале')),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now, verbose_name='создан')),
                ('consumer_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='content_type_set_for_action', to='contenttypes.contenttype', verbose_name='Consumer Type')),
                ('profile', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='Профиль')),
            ],
            options={
                'verbose_name': 'действие',
                'verbose_name_plural': 'Действия',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Diff',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('version', models.PositiveIntegerField(verbose_name='Версия')),
                ('change', models.TextField()),
                ('field', models.CharField(blank=True, max_length=255, null=True, verbose_name='Поле')),
                ('action', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_history.action')),
            ],
            options={
                'verbose_name': 'отличие',
                'verbose_name_plural': 'Отличия',
                'unique_together': {('action', 'field')},
                'index_together': {('version', 'field')},
            },
        ),
        migrations.AddField(
            model_name='action',
            name='rollback_to',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='rolled_back_from', to='django_history.diff', verbose_name='Откатить до'),
        ),
        migrations.AlterIndexTogether(
            name='action',
            index_together={('consumer_type', 'consumer_pk')},
        ),
    ]
