# Generated by Django 3.2.3 on 2021-06-03 00:53

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='ContainerTemplate',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True)),
                ('image_url', models.URLField()),
                ('exposed_port', default.models.PortField()),
            ],
        ),
        migrations.CreateModel(
            name='Service',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='VolumeDefinition',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('container_dir', models.CharField(max_length=4096)),
                ('required', models.BooleanField(default=True)),
                ('template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='default.containertemplate')),
            ],
        ),
        migrations.CreateModel(
            name='Volume',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('host_dir', models.CharField(max_length=4096, unique=True)),
                ('definition', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='default.volumedefinition')),
                ('service', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='default.service')),
            ],
        ),
        migrations.CreateModel(
            name='ServiceDefinition',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True)),
                ('templates', models.ManyToManyField(related_name='service_definitions', related_query_name='service_definitions', to='default.ContainerTemplate')),
            ],
        ),
        migrations.AddField(
            model_name='service',
            name='definition',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='default.servicedefinition'),
        ),
        migrations.AddConstraint(
            model_name='volumedefinition',
            constraint=models.UniqueConstraint(fields=('container_dir', 'template'), name='unique_container_dir_per_template'),
        ),
        migrations.AddConstraint(
            model_name='volume',
            constraint=models.UniqueConstraint(fields=('host_dir', 'service'), name='unique_host_dir_per_service'),
        ),
        migrations.AddConstraint(
            model_name='volume',
            constraint=models.UniqueConstraint(fields=('definition', 'service'), name='unique_volume_definition_per_service'),
        ),
        migrations.AddConstraint(
            model_name='volume',
            constraint=models.UniqueConstraint(condition=models.Q(('host_dir__startswith', '/')), fields=('host_dir',), name='unique_absolute_host_dir'),
        ),
    ]

# Generated by Django 3.2.3 on 2021-06-03 00:53

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='ContainerTemplate',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True)),
                ('image_url', models.URLField()),
                ('exposed_port', default.models.PortField()),
            ],
        ),
        migrations.CreateModel(
            name='Service',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='VolumeDefinition',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('container_dir', models.CharField(max_length=4096)),
                ('required', models.BooleanField(default=True)),
                ('template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='default.containertemplate')),
            ],
        ),
        migrations.CreateModel(
            name='Volume',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('host_dir', models.CharField(max_length=4096, unique=True)),
                ('definition', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='default.volumedefinition')),
                ('service', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='default.service')),
            ],
        ),
        migrations.CreateModel(
            name='ServiceDefinition',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True)),
                ('templates', models.ManyToManyField(related_name='service_definitions', related_query_name='service_definitions', to='default.ContainerTemplate')),
            ],
        ),
        migrations.AddField(
            model_name='service',
            name='definition',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='default.servicedefinition'),
        ),
        migrations.AddConstraint(
            model_name='volumedefinition',
            constraint=models.UniqueConstraint(fields=('container_dir', 'template'), name='unique_container_dir_per_template'),
        ),
        migrations.AddConstraint(
            model_name='volume',
            constraint=models.UniqueConstraint(fields=('host_dir', 'service'), name='unique_host_dir_per_service'),
        ),
        migrations.AddConstraint(
            model_name='volume',
            constraint=models.UniqueConstraint(fields=('definition', 'service'), name='unique_volume_definition_per_service'),
        ),
        migrations.AddConstraint(
            model_name='volume',
            constraint=models.UniqueConstraint(condition=models.Q(('host_dir__startswith', '/')), fields=('host_dir',), name='unique_absolute_host_dir'),
        ),
    ]

# Generated by Django 3.2.3 on 2021-06-03 00:53