# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2015-12-10 09:20
from __future__ import unicode_literals

from django.conf import settings
import django.contrib.postgres.fields.jsonb
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='Action',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4, unique=True, verbose_name='UUID')),
                ('name', models.CharField(max_length=255, verbose_name='\u0421\u043e\u0431\u044b\u0442\u0438\u0435')),
            ],
            options={
                'verbose_name': '\u0421\u043e\u0431\u044b\u0442\u0438\u0435',
                'verbose_name_plural': '\u0421\u043e\u0431\u044b\u0442\u0438\u044f',
            },
        ),
        migrations.CreateModel(
            name='ActionGroup',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435')),
            ],
            options={
                'verbose_name': '\u0413\u0440\u0443\u043f\u043f\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439',
                'verbose_name_plural': '\u0413\u0440\u0443\u043f\u043f\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u0439',
            },
        ),
        migrations.CreateModel(
            name='Client',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(unique=True, verbose_name='UUID')),
                ('login', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u0418\u043c\u044f')),
                ('description', models.TextField(blank=True, null=True, verbose_name='\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435')),
                ('create_date', models.DateTimeField(auto_now_add=True, verbose_name='\u0414\u0430\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f')),
                ('change_date', models.DateTimeField(auto_now=True, verbose_name='\u0414\u0430\u0442\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f')),
                ('os', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u041e\u0421')),
                ('ip', models.GenericIPAddressField(blank=True, null=True, verbose_name='IP \u0430\u0434\u0440\u0435\u0441')),
                ('user_name', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f')),
                ('computer_name', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u0418\u043c\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430')),
                ('domain', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u0414\u043e\u043c\u0435\u043d')),
            ],
            options={
                'verbose_name': '\u041a\u041c-\u043a\u043b\u0438\u0435\u043d\u0442',
                'verbose_name_plural': '\u041a\u041c-\u043a\u043b\u0438\u0435\u043d\u0442\u044b',
            },
        ),
        migrations.CreateModel(
            name='ClientActionLog',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('params', django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True, verbose_name='\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b')),
                ('date', models.DateTimeField(verbose_name='\u0414\u0430\u0442\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f')),
                ('action', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='statistics.Action')),
                ('client', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='actions', to='statistics.Client')),
            ],
            options={
                'ordering': ['date'],
                'verbose_name': '\u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u041a\u041c-\u043a\u043b\u0438\u0435\u043d\u0442\u0430',
                'verbose_name_plural': '\u0421\u043e\u0431\u044b\u0442\u0438\u044f \u041a\u041c-\u043a\u043b\u0438\u0435\u043d\u0442\u0430',
            },
        ),
        migrations.CreateModel(
            name='Dealer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(unique=True, verbose_name='UUID \u0434\u0438\u043b\u0435\u0440\u0430')),
                ('name', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u0418\u043c\u044f \u0434\u0438\u043b\u0435\u0440\u0430')),
                ('action_group_logging', models.ManyToManyField(blank=True, to='statistics.ActionGroup')),
                ('action_logging', models.ManyToManyField(blank=True, to='statistics.Action')),
            ],
            options={
                'verbose_name': '\u0414\u0438\u043b\u0435\u0440',
                'verbose_name_plural': '\u0414\u0438\u043b\u0435\u0440\u044b',
            },
        ),
        migrations.CreateModel(
            name='HistoricalClient',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('uuid', models.UUIDField(db_index=True, verbose_name='UUID')),
                ('login', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u0418\u043c\u044f')),
                ('description', models.TextField(blank=True, null=True, verbose_name='\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435')),
                ('create_date', models.DateTimeField(blank=True, editable=False, verbose_name='\u0414\u0430\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f')),
                ('change_date', models.DateTimeField(blank=True, editable=False, verbose_name='\u0414\u0430\u0442\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f')),
                ('os', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u041e\u0421')),
                ('ip', models.GenericIPAddressField(blank=True, null=True, verbose_name='IP \u0430\u0434\u0440\u0435\u0441')),
                ('user_name', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f')),
                ('computer_name', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u0418\u043c\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430')),
                ('domain', models.CharField(blank=True, max_length=255, null=True, verbose_name='\u0414\u043e\u043c\u0435\u043d')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('dealer', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='statistics.Dealer')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
                'verbose_name': 'historical \u041a\u041c-\u043a\u043b\u0438\u0435\u043d\u0442',
            },
        ),
        migrations.AddField(
            model_name='client',
            name='dealer',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='clients', to='statistics.Dealer'),
        ),
        migrations.AddField(
            model_name='action',
            name='action_group',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='statistics.ActionGroup'),
        ),
    ]
