# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-18 05:55
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Entity',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ],
            options={
                '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=45, unique=True)),
                ('display', models.CharField(max_length=45, unique=True)),
                ('type', models.IntegerField(choices=[('TYPE_INT', 0), ('TYPE_FLOAT', 1), ('TYPE_STRING', 2), ('TYPE_DATETIME', 3), ('TYPE_IP', 4)], default=2)),
                ('required', models.BooleanField(default=True)),
                ('multi', models.BooleanField(default=False)),
                ('unique', models.BooleanField(default=False)),
                ('default', models.BinaryField()),
                ('deleted', models.BooleanField(default=False)),
            ],
            options={
                'db_table': 'field',
            },
        ),
        migrations.CreateModel(
            name='FieldHistory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=45, unique=True)),
                ('display', models.CharField(max_length=45, unique=True)),
                ('type', models.IntegerField(choices=[('TYPE_INT', 0), ('TYPE_FLOAT', 1), ('TYPE_STRING', 2), ('TYPE_DATETIME', 3), ('TYPE_IP', 4)], default=2)),
                ('required', models.BooleanField(default=True)),
                ('multi', models.BooleanField(default=False)),
                ('unique', models.BooleanField(default=False)),
                ('default', models.BinaryField()),
                ('deleted', models.BooleanField(default=False)),
                ('timestamp', models.DateTimeField(db_index=True)),
                ('field', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.Field')),
            ],
            options={
                'db_table': 'field_history',
            },
        ),
        migrations.CreateModel(
            name='Relationship',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='source_id', to='assets.Field')),
                ('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='target_id', to='assets.Field')),
            ],
            options={
                'db_table': 'relationship',
            },
        ),
        migrations.CreateModel(
            name='Schema',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=45, unique=True)),
                ('display', models.CharField(max_length=45, unique=True)),
                ('deleted', models.BooleanField(default=False)),
            ],
            options={
                'db_table': 'schema',
            },
        ),
        migrations.CreateModel(
            name='Value',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.BinaryField()),
                ('entity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.Entity')),
                ('field', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.Field')),
            ],
            options={
                'db_table': 'value',
            },
        ),
        migrations.CreateModel(
            name='ValueHistory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.BinaryField()),
                ('timestamp', models.DateTimeField(db_index=True)),
                ('deleted', models.BooleanField(default=False)),
                ('entity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.Entity')),
                ('field', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.Field')),
            ],
            options={
                'db_table': 'value_history',
            },
        ),
        migrations.AddField(
            model_name='fieldhistory',
            name='schema',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.Schema'),
        ),
        migrations.AddField(
            model_name='field',
            name='schema',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.Schema'),
        ),
        migrations.AddField(
            model_name='entity',
            name='schema',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assets.Schema'),
        ),
        migrations.AlterUniqueTogether(
            name='field',
            unique_together=set([('schema', 'display'), ('schema', 'name')]),
        ),
    ]
