# Generated by Django 4.1.3 on 2023-06-13 09:39

from django.conf import settings
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),
        ('auth', '0012_alter_user_first_name_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='ContainerType',
            fields=[
                ('dbid', models.UUIDField(default=uuid.uuid4, editable=False, help_text='UUID primary key', primary_key=True, serialize=False)),
                ('name', models.CharField(help_text='Name of the container type', max_length=256)),
                ('id', models.CharField(blank=True, help_text='Identifier of the container type', max_length=256, null=True)),
                ('version', models.CharField(blank=True, help_text='Version of the container type', max_length=256, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='DataSetBase',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, help_text='UUID primary key', primary_key=True, serialize=False)),
                ('_replaced_by_field', models.OneToOneField(blank=True, help_text="Other instance that replaces this instance. Don't use this field but the getter and setter functions", null=True, on_delete=django.db.models.deletion.PROTECT, related_name='_replaces_field', to='scidatacontainer_db.datasetbase')),
            ],
        ),
        migrations.CreateModel(
            name='File',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, help_text='UUID primary key', primary_key=True, serialize=False)),
                ('name', models.CharField(help_text='File name inside the ZDC dataset', max_length=256)),
                ('size', models.IntegerField(help_text='File size in bytes')),
                ('content', models.JSONField(blank=True, help_text='Dictionary containing the content of a JSON file', null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Keyword',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, help_text='UUID primary key', primary_key=True, serialize=False)),
                ('name', models.CharField(help_text='String representation of a keyword', max_length=256)),
            ],
        ),
        migrations.CreateModel(
            name='Software',
            fields=[
                ('dbid', models.UUIDField(default=uuid.uuid4, editable=False, help_text='UUID primary_key', primary_key=True, serialize=False)),
                ('name', models.CharField(help_text='Name of the Software package', max_length=256)),
                ('version', models.CharField(help_text='Version of the software package', max_length=256)),
                ('id', models.CharField(help_text='Identifier of the software package', max_length=256)),
                ('id_type', models.CharField(help_text='Type of the given identifier', max_length=256)),
            ],
        ),
        migrations.CreateModel(
            name='DataSet',
            fields=[
                ('datasetbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='scidatacontainer_db.datasetbase')),
                ('upload_time', models.DateTimeField(auto_now_add=True, help_text='Datetime of server uplaod')),
                ('complete', models.BooleanField(help_text='Complete flag to ensure overwrite protection')),
                ('valid', models.BooleanField(help_text='Valid flag to mark erroneous datasets')),
                ('invalidation_comment', models.TextField(blank=True, default='', help_text='Comment to describe why this dataset is invalid')),
                ('size', models.IntegerField(help_text='Size of the dataset in bytes')),
                ('server_path', models.CharField(blank=True, help_text='File path to find the file on the server', max_length=512, null=True)),
                ('created', models.DateTimeField(help_text='Creation timestamp of the container')),
                ('storage_time', models.DateTimeField(help_text='Timestamp of storage of the container')),
                ('static', models.BooleanField(default=False, help_text='Flag for static containers')),
                ('hash', models.CharField(blank=True, help_text='Hash of the container', max_length=256, null=True)),
                ('model_version', models.CharField(help_text='Version of the data model', max_length=256)),
                ('author', models.CharField(max_length=256)),
                ('email', models.EmailField(max_length=254)),
                ('organization', models.CharField(blank=True, help_text='Affiliation of the author', max_length=1024)),
                ('comment', models.TextField(blank=True)),
                ('title', models.CharField(max_length=256)),
                ('description', models.TextField(blank=True)),
                ('timestamp', models.DateTimeField(blank=True, null=True)),
                ('doi', models.CharField(blank=True, max_length=512)),
                ('license', models.TextField(blank=True, help_text='Name or text of the license')),
                ('container_type', models.ForeignKey(help_text='ContainerType of this dataset', on_delete=django.db.models.deletion.PROTECT, related_name='instances', to='scidatacontainer_db.containertype')),
                ('content', models.ManyToManyField(help_text='List of files included in the container', related_name='included_in', to='scidatacontainer_db.file')),
                ('keywords', models.ManyToManyField(blank=True, help_text='List of keywords', to='scidatacontainer_db.keyword')),
                ('owner', models.ForeignKey(blank=True, help_text='Owner of the dataset', on_delete=django.db.models.deletion.PROTECT, related_name='owner_of', to=settings.AUTH_USER_MODEL)),
                ('used_software', models.ManyToManyField(blank=True, help_text='List of software packages used in the dataset', related_name='used_by', to='scidatacontainer_db.software')),
            ],
            options={
                'permissions': (('view_dataset', 'Read only access'), ('change_dataset', 'Read and write access')),
                'default_permissions': (),
            },
            bases=('scidatacontainer_db.datasetbase',),
        ),
        migrations.CreateModel(
            name='DataSetUserObjectPermission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('permission', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.permission')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
                ('content_object', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scidatacontainer_db.dataset')),
            ],
            options={
                'abstract': False,
                'unique_together': {('user', 'permission', 'content_object')},
            },
        ),
        migrations.CreateModel(
            name='DataSetGroupObjectPermission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.group')),
                ('permission', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.permission')),
                ('content_object', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scidatacontainer_db.dataset')),
            ],
            options={
                'abstract': False,
                'unique_together': {('group', 'permission', 'content_object')},
            },
        ),
    ]
