# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-20 04:48
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='ContentType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(max_length=64, unique=True, verbose_name='Type')),
            ],
            options={
                'verbose_name_plural': 'Content Types',
                'verbose_name': 'Content type',
                'db_table': 'content_type',
            },
        ),
        migrations.CreateModel(
            name='Entity',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('entity_name', models.CharField(max_length=64, unique=True, verbose_name='Email Address')),
                ('primary_field', models.CharField(max_length=64, verbose_name='Primary Field')),
                ('display_format', models.CharField(blank=True, max_length=255, null=True, verbose_name='Display Format')),
                ('status', models.CharField(choices=[('A', 'Active'), ('I', 'Inactive')], db_column='status', default='A', max_length=1, verbose_name='Status')),
            ],
            options={
                'verbose_name_plural': 'Entities',
                'verbose_name': 'Entity',
                'db_table': 'entity',
            },
        ),
        migrations.CreateModel(
            name='Field',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=80, verbose_name='Name')),
                ('entity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='fields', to='audit_trail.Entity', verbose_name='Entity')),
            ],
            options={
                'verbose_name_plural': 'Fields',
                'db_table': 'field',
                'verbose_name': 'Field',
            },
        ),
        migrations.CreateModel(
            name='FieldDiff',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
            ],
            options={
                'verbose_name_plural': 'Field Diffs',
                'verbose_name': 'Field Diff',
                'db_table': 'fielddiff',
            },
        ),
        migrations.CreateModel(
            name='ParentEntityChildFieldMap',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('child_field', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='audit_trail.Field')),
                ('parent_entity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='audit_trail.Entity')),
            ],
            options={
                'db_table': 'parent_entity_child_field_map',
            },
        ),
        migrations.CreateModel(
            name='StorageBin',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('stored_at', models.DateTimeField(auto_now_add=True, verbose_name='Stored At')),
                ('code', models.CharField(max_length=16, unique=True, verbose_name='Code')),
                ('data', models.BinaryField()),
                ('status', models.CharField(choices=[('A', 'Active'), ('I', 'Inactive')], db_column='status', default='A', max_length=1, verbose_name='Status')),
                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='audit_trail.ContentType', verbose_name='Content Type')),
            ],
            options={
                'verbose_name_plural': 'Storage Bins',
                'verbose_name': 'Storage Bin',
                'db_table': 'storage_bin',
            },
        ),
        migrations.CreateModel(
            name='Xaction',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('xaction_type', models.CharField(choices=[('I', 'Insert'), ('U', 'Update'), ('D', 'Delete')], max_length=1, verbose_name='Xaction Type')),
                ('display_text', models.CharField(blank=True, max_length=128, null=True, verbose_name='Display Text')),
                ('pfield_val', models.CharField(max_length=128, verbose_name='Primary Field Value')),
                ('ts', models.DateTimeField(auto_now_add=True, verbose_name='Time Stamp')),
                ('entity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='xactions', to='audit_trail.Entity', verbose_name='Entity')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
            ],
            options={
                'verbose_name_plural': 'Xactions',
                'db_table': 'xaction',
                'verbose_name': 'Xaction',
                'ordering': ['-ts'],
            },
        ),
        migrations.CreateModel(
            name='XactionParentEntityChildFieldMap',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('field_val', models.CharField(max_length=128)),
                ('parent_entity_child_fields', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='audit_trail.ParentEntityChildFieldMap')),
                ('xaction', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='xaction_parent_entity_child_fields', to='audit_trail.Xaction')),
            ],
            options={
                'db_table': 'xaction_parent_entity_child_field_map',
            },
        ),
        migrations.AddField(
            model_name='fielddiff',
            name='curr_val',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='curr_field_diff', to='audit_trail.StorageBin', verbose_name='Current Value'),
        ),
        migrations.AddField(
            model_name='fielddiff',
            name='field',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='audit_trail.Field', verbose_name='Field'),
        ),
        migrations.AddField(
            model_name='fielddiff',
            name='prev_val',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='prev_field_diff', to='audit_trail.StorageBin', verbose_name='Previous Value'),
        ),
        migrations.AddField(
            model_name='fielddiff',
            name='xaction',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='audit_trail.Xaction', verbose_name='Xaction'),
        ),
        migrations.AlterUniqueTogether(
            name='field',
            unique_together=set([('name', 'entity')]),
        ),
    ]
