# Generated by Django 2.2 on 2019-04-26 02:01

import clouds.base.models
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('engines', '0044_auto_20190424_2135'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='DataEngine',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False)),
                ('name', models.CharField(max_length=50, unique=True)),
                ('_remedy_script', models.TextField(blank=True, default='', max_length=5120)),
                ('public', models.BooleanField(default=False)),
                ('enabled', models.BooleanField(default=True)),
                ('modified_time', models.DateTimeField(auto_now=True)),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('remark', models.CharField(blank=True, max_length=100, null=True)),
                ('type', models.PositiveIntegerField(choices=[(0, 'ralational'), (1, 'raw'), (2, 'freetext'), (3, 'semistructed'), (4, 'event'), (5, 'graph')])),
                ('endpoint', models.CharField(blank=True, max_length=200, null=True)),
                ('description', models.TextField(max_length=5120)),
                ('component', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='engines.Component')),
                ('engine', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='engines.Engine')),
                ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='DataInstance',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False)),
                ('name', models.CharField(max_length=50)),
                ('uri_suffix', models.CharField(help_text='the only approach to access this data instance.', max_length=200, verbose_name='suffix of the final uri')),
                ('remedy_script_todo', models.TextField(blank=True, max_length=5120, null=True)),
                ('remark', models.CharField(blank=True, max_length=100, null=True)),
                ('public', models.BooleanField(default=False)),
                ('created_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('built_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('status', models.PositiveIntegerField(choices=[(0, 'null'), (1, 'active'), (2, 'block'), (3, 'suspend'), (4, 'stop'), (5, 'breakdown'), (6, 'pause'), (7, 'instance_lost')], default=0, editable=False)),
                ('deleting', models.BooleanField(default=False, editable=False)),
                ('cluster', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='engines.Cluster')),
            ],
            bases=(models.Model, clouds.base.models.OperatableMixin),
        ),
        migrations.CreateModel(
            name='DataSource',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False)),
                ('name', models.CharField(max_length=50, unique=True)),
                ('_remedy_script', models.TextField(blank=True, default='', max_length=5120)),
                ('public', models.BooleanField(default=False)),
                ('enabled', models.BooleanField(default=True)),
                ('modified_time', models.DateTimeField(auto_now=True)),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('remark', models.CharField(blank=True, max_length=100, null=True)),
                ('uri', models.CharField(help_text='specify the protocol and address used to sync this remote data source.', max_length=200)),
                ('sync_interval', models.PositiveIntegerField(default=3600, validators=[django.core.validators.MinValueValidator(1)], verbose_name='sync interval in seconds')),
                ('description', models.TextField(max_length=5120)),
                ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Dataset',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False)),
                ('name', models.CharField(max_length=50, unique=True)),
                ('_remedy_script', models.TextField(blank=True, default='', max_length=5120)),
                ('public', models.BooleanField(default=False)),
                ('enabled', models.BooleanField(default=True)),
                ('modified_time', models.DateTimeField(auto_now=True)),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('remark', models.CharField(blank=True, max_length=100, null=True)),
                ('uri', models.CharField(max_length=200)),
                ('type', models.PositiveIntegerField(blank=True, choices=[(0, 'ralational'), (1, 'raw'), (2, 'freetext'), (3, 'semistructed'), (4, 'event'), (5, 'graph')], null=True)),
                ('size', models.PositiveIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1)])),
                ('description', models.TextField(max_length=5120)),
                ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
                ('source', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='data.DataSource')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='DataInstanceOperation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('batch_uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False)),
                ('script', models.TextField(blank=True, default='', max_length=5120)),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('started_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('completed_time', models.DateTimeField(blank=True, editable=False, null=True)),
                ('status', models.CharField(choices=[('success', 'success'), ('failed', 'failed'), ('running', 'running'), ('waiting', 'waiting')], default='running', editable=False, max_length=50)),
                ('tidied', models.BooleanField(default=False, editable=False)),
                ('manual', models.BooleanField(default=True, editable=False)),
                ('operation', models.CharField(choices=[('start', 'start'), ('stop', 'stop')], default='start', max_length=50)),
                ('log', models.TextField(editable=False, max_length=51200, null=True)),
                ('serial', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='data.DataInstanceOperation')),
                ('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='data.DataInstance')),
            ],
            options={
                'verbose_name': 'operation',
                'ordering': ['-started_time', '-completed_time', '-pk'],
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='datainstance',
            name='dataset',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='data.Dataset'),
        ),
        migrations.AddField(
            model_name='datainstance',
            name='engine',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='data.DataEngine'),
        ),
        migrations.AddField(
            model_name='datainstance',
            name='owner',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterUniqueTogether(
            name='datainstance',
            unique_together={('engine', 'uri_suffix'), ('name', 'cluster', 'owner')},
        ),
    ]
