# Generated by Django 1.9.11 on 2016-11-28 22:03
# -- with some slight modifications
# flake8: noqa

from django.conf import settings
from django.contrib.postgres import fields
from django.contrib.postgres.fields import hstore
from django.db import migrations, models
from django.db.models.deletion import CASCADE, PROTECT, SET_NULL

import edd.fields
import main.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("auth", "0007_alter_validators_add_error_messages"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Attachment",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "file",
                    edd.fields.FileField(
                        help_text="Path to file data.",
                        max_length=255,
                        upload_to="%Y/%m/%d",
                        verbose_name="File Path",
                    ),
                ),
                (
                    "filename",
                    models.CharField(
                        help_text="Name of attachment file.",
                        max_length=255,
                        verbose_name="File Name",
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True,
                        help_text="Description of attachment file contents.",
                        verbose_name="Description",
                    ),
                ),
                (
                    "mime_type",
                    models.CharField(
                        blank=True,
                        help_text="MIME ContentType of the attachment.",
                        max_length=255,
                        null=True,
                        verbose_name="MIME",
                    ),
                ),
                (
                    "file_size",
                    models.IntegerField(
                        default=0,
                        help_text="Total byte size of the attachment.",
                        verbose_name="Size",
                    ),
                ),
            ],
            options={"db_table": "attachment"},
        ),
        migrations.CreateModel(
            name="Comment",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "body",
                    models.TextField(
                        help_text="Content of the comment.", verbose_name="Comment"
                    ),
                ),
            ],
            options={"db_table": "comment"},
        ),
        migrations.CreateModel(
            name="Datasource",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The source used for information on a measurement type.",
                        max_length=255,
                        verbose_name="Datasource",
                    ),
                ),
                (
                    "url",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="URL of the source.",
                        max_length=255,
                        verbose_name="URL",
                    ),
                ),
                (
                    "download_date",
                    models.DateField(
                        auto_now=True,
                        help_text="Date when information was accessed and copied.",
                        verbose_name="Download Date",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="EDDObject",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "meta_store",
                    hstore.HStoreField(
                        blank=True,
                        default=dict,
                        help_text="Metadata dictionary.",
                        verbose_name="Metadata",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="Name of this object.",
                        max_length=255,
                        verbose_name="Name",
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True,
                        help_text="Description of this object.",
                        null=True,
                        verbose_name="Description",
                    ),
                ),
                (
                    "active",
                    models.BooleanField(
                        default=True,
                        help_text="Flag showing if this object is active and displayed.",
                        verbose_name="Active",
                    ),
                ),
                (
                    "uuid",
                    models.UUIDField(
                        editable=False,
                        help_text="Unique identifier for this object.",
                        unique=True,
                        verbose_name="UUID",
                    ),
                ),
            ],
            options={"db_table": "edd_object"},
            bases=(models.Model, main.models.EDDSerialize),
        ),
        migrations.CreateModel(
            name="EveryonePermission",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "permission_type",
                    models.CharField(
                        choices=[("N", "None"), ("R", "Read"), ("W", "Write")],
                        default="N",
                        help_text="Type of permission.",
                        max_length=8,
                        verbose_name="Permission",
                    ),
                ),
            ],
            options={"db_table": "study_public_permission"},
        ),
        migrations.CreateModel(
            name="GroupPermission",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "permission_type",
                    models.CharField(
                        choices=[("N", "None"), ("R", "Read"), ("W", "Write")],
                        default="N",
                        help_text="Type of permission.",
                        max_length=8,
                        verbose_name="Permission",
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        help_text="Group this permission applies to.",
                        on_delete=CASCADE,
                        related_name="grouppermission_set",
                        to="auth.Group",
                        verbose_name="Group",
                    ),
                ),
            ],
            options={"db_table": "study_group_permission"},
        ),
        migrations.CreateModel(
            name="Measurement",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "meta_store",
                    hstore.HStoreField(
                        blank=True,
                        default=dict,
                        help_text="Metadata dictionary.",
                        verbose_name="Metadata",
                    ),
                ),
                (
                    "active",
                    models.BooleanField(
                        default=True,
                        help_text="Flag indicating this Measurement is active and should be displayed.",
                        verbose_name="Active",
                    ),
                ),
                (
                    "compartment",
                    models.CharField(
                        choices=[
                            ("0", "N/A"),
                            ("1", "Intracellular/Cytosol (Cy)"),
                            ("2", "Extracellular"),
                        ],
                        default="0",
                        help_text="Compartment of the cell for this Measurement.",
                        max_length=1,
                        verbose_name="Compartment",
                    ),
                ),
                (
                    "measurement_format",
                    models.CharField(
                        choices=[
                            ("0", "scalar"),
                            ("1", "vector"),
                            ("2", "histogram"),
                            ("3", "sigma"),
                        ],
                        default="0",
                        help_text="Enumeration of value formats for this Measurement.",
                        max_length=2,
                        verbose_name="Format",
                    ),
                ),
                (
                    "experimenter",
                    models.ForeignKey(
                        blank=True,
                        help_text="EDD User that set up the experimental conditions of this Measurement.",
                        null=True,
                        on_delete=PROTECT,
                        related_name="measurement_experimenter_set",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Experimenter",
                    ),
                ),
            ],
            options={"db_table": "measurement"},
            bases=(models.Model, main.models.EDDSerialize),
        ),
        migrations.CreateModel(
            name="MeasurementType",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "type_name",
                    models.CharField(
                        help_text="Name of this Measurement Type.",
                        max_length=255,
                        verbose_name="Measurement Type",
                    ),
                ),
                (
                    "short_name",
                    models.CharField(
                        blank=True,
                        help_text="Short name used as an ID for the Measurement Type in SBML output.",
                        max_length=255,
                        null=True,
                        verbose_name="Short Name",
                    ),
                ),
                (
                    "type_group",
                    models.CharField(
                        choices=[
                            ("_", "Generic"),
                            ("m", "Metabolite"),
                            ("g", "Gene Identifier"),
                            ("p", "Protein Identifer"),
                            ("h", "Phosphor"),
                        ],
                        default="_",
                        help_text="Class of data for this Measurement Type.",
                        max_length=8,
                        verbose_name="Type Group",
                    ),
                ),
                (
                    "uuid",
                    models.UUIDField(
                        editable=False,
                        help_text="Unique ID for this Measurement Type.",
                        unique=True,
                        verbose_name="UUID",
                    ),
                ),
            ],
            options={"db_table": "measurement_type"},
            bases=(models.Model, main.models.EDDSerialize),
        ),
        migrations.CreateModel(
            name="MeasurementUnit",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "unit_name",
                    models.CharField(
                        help_text="Name for unit of measurement.",
                        max_length=255,
                        unique=True,
                        verbose_name="Name",
                    ),
                ),
                (
                    "display",
                    models.BooleanField(
                        default=True,
                        help_text="Flag indicating the units should be displayed along with values.",
                        verbose_name="Display",
                    ),
                ),
                (
                    "alternate_names",
                    models.CharField(
                        blank=True,
                        help_text="Alternative names for the unit.",
                        max_length=255,
                        null=True,
                        verbose_name="Alternate Names",
                    ),
                ),
                (
                    "type_group",
                    models.CharField(
                        choices=[
                            ("_", "Generic"),
                            ("m", "Metabolite"),
                            ("g", "Gene Identifier"),
                            ("p", "Protein Identifer"),
                            ("h", "Phosphor"),
                        ],
                        default="_",
                        help_text="Type of measurement for which this unit is used.",
                        max_length=8,
                        verbose_name="Group",
                    ),
                ),
            ],
            options={"db_table": "measurement_unit"},
        ),
        migrations.CreateModel(
            name="MeasurementValue",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "x",
                    fields.ArrayField(
                        base_field=models.DecimalField(decimal_places=5, max_digits=16),
                        help_text="X-axis value(s) for this point.",
                        size=None,
                        verbose_name="X",
                    ),
                ),
                (
                    "y",
                    fields.ArrayField(
                        base_field=models.DecimalField(decimal_places=5, max_digits=16),
                        help_text="Y-axis value(s) for this point.",
                        size=None,
                        verbose_name="Y",
                    ),
                ),
                (
                    "measurement",
                    models.ForeignKey(
                        help_text="The Measurement containing this point of data.",
                        on_delete=CASCADE,
                        to="main.Measurement",
                        verbose_name="Measurement",
                    ),
                ),
            ],
            options={"db_table": "measurement_value"},
        ),
        migrations.CreateModel(
            name="MetaboliteExchange",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "reactant_name",
                    edd.fields.VarCharField(
                        help_text="The reactant name used in for this exchange reaction.",
                        verbose_name="Reactant Name",
                    ),
                ),
                (
                    "exchange_name",
                    edd.fields.VarCharField(
                        help_text="The exchange name used in the model.",
                        verbose_name="Exchange Name",
                    ),
                ),
            ],
            options={"db_table": "measurement_type_to_exchange"},
        ),
        migrations.CreateModel(
            name="MetaboliteSpecies",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "species",
                    edd.fields.VarCharField(
                        help_text="Species name used in the model for this metabolite.",
                        verbose_name="Species",
                    ),
                ),
            ],
            options={"db_table": "measurement_type_to_species"},
        ),
        migrations.CreateModel(
            name="MetadataGroup",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "group_name",
                    models.CharField(
                        help_text="Name of the group/class of metadata.",
                        max_length=255,
                        unique=True,
                        verbose_name="Group Name",
                    ),
                ),
            ],
            options={"db_table": "metadata_group"},
        ),
        migrations.CreateModel(
            name="MetadataType",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "type_name",
                    models.CharField(
                        help_text="Name for Metadata Type",
                        max_length=255,
                        verbose_name="Name",
                    ),
                ),
                (
                    "type_i18n",
                    models.CharField(
                        blank=True,
                        help_text="i18n key used for naming this Metadata Type.",
                        max_length=255,
                        null=True,
                        verbose_name="i18n Key",
                    ),
                ),
                (
                    "type_field",
                    models.CharField(
                        blank=True,
                        default=None,
                        help_text="Model field where metadata is stored; blank stores in metadata dictionary.",
                        max_length=255,
                        null=True,
                        verbose_name="Field Name",
                    ),
                ),
                (
                    "input_size",
                    models.IntegerField(
                        default=6,
                        help_text="Size of input fields for values of this Metadata Type.",
                        verbose_name="Input Size",
                    ),
                ),
                (
                    "input_type",
                    models.CharField(
                        blank=True,
                        help_text="Type of input fields for values of this Metadata Type.",
                        max_length=255,
                        null=True,
                        verbose_name="Input Type",
                    ),
                ),
                (
                    "default_value",
                    models.CharField(
                        blank=True,
                        help_text="Default value for this Metadata Type.",
                        max_length=255,
                        verbose_name="Default Value",
                    ),
                ),
                (
                    "prefix",
                    models.CharField(
                        blank=True,
                        help_text="Prefix text appearing before values of this Metadata Type.",
                        max_length=255,
                        verbose_name="Prefix",
                    ),
                ),
                (
                    "postfix",
                    models.CharField(
                        blank=True,
                        help_text="Postfix text appearing after values of this Metadata Type.",
                        max_length=255,
                        verbose_name="Postfix",
                    ),
                ),
                (
                    "for_context",
                    models.CharField(
                        choices=[("S", "Study"), ("L", "Line"), ("A", "Assay")],
                        help_text="Type of EDD Object this Metadata Type may be added to.",
                        max_length=8,
                        verbose_name="Context",
                    ),
                ),
                (
                    "type_class",
                    models.CharField(
                        blank=True,
                        help_text="Type of data saved for this Metadata Type; blank saves a string type.",
                        max_length=255,
                        null=True,
                        verbose_name="Type Class",
                    ),
                ),
                (
                    "uuid",
                    models.UUIDField(
                        editable=False,
                        help_text="Unique identifier for this Metadata Type.",
                        unique=True,
                        verbose_name="UUID",
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        blank=True,
                        help_text="Group for this Metadata Type",
                        null=True,
                        on_delete=PROTECT,
                        to="main.MetadataGroup",
                        verbose_name="Group",
                    ),
                ),
            ],
            options={"db_table": "metadata_type"},
            bases=(models.Model, main.models.EDDSerialize),
        ),
        migrations.CreateModel(
            name="Update",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "mod_time",
                    models.DateTimeField(
                        auto_now_add=True,
                        help_text="Timestamp of the update.",
                        verbose_name="Modified",
                    ),
                ),
                (
                    "path",
                    models.TextField(
                        blank=True,
                        help_text="URL path used to trigger this update.",
                        null=True,
                        verbose_name="URL Path",
                    ),
                ),
                (
                    "origin",
                    models.TextField(
                        blank=True,
                        help_text="Host origin of the request triggering this update.",
                        null=True,
                        verbose_name="Origin Host",
                    ),
                ),
                (
                    "mod_by",
                    models.ForeignKey(
                        editable=False,
                        help_text="The user performing the update.",
                        null=True,
                        on_delete=PROTECT,
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
            ],
            options={"db_table": "update_info"},
            bases=(models.Model, main.models.EDDSerialize),
        ),
        migrations.CreateModel(
            name="UserPermission",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "permission_type",
                    models.CharField(
                        choices=[("N", "None"), ("R", "Read"), ("W", "Write")],
                        default="N",
                        help_text="Type of permission.",
                        max_length=8,
                        verbose_name="Permission",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="User this permission applies to.",
                        on_delete=CASCADE,
                        related_name="userpermission_set",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
            ],
            options={"db_table": "study_user_permission"},
        ),
        migrations.CreateModel(
            name="WorklistColumn",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "heading",
                    models.CharField(
                        blank=True,
                        help_text="Column header text.",
                        max_length=255,
                        null=True,
                        verbose_name="Heading",
                    ),
                ),
                (
                    "default_value",
                    models.CharField(
                        blank=True,
                        help_text="Default value for this column.",
                        max_length=255,
                        null=True,
                        verbose_name="Default Value",
                    ),
                ),
                (
                    "help_text",
                    models.TextField(
                        blank=True,
                        help_text="UI text to display explaining how to modify this column.",
                        null=True,
                        verbose_name="Help Text",
                    ),
                ),
                (
                    "ordering",
                    models.IntegerField(
                        blank=True,
                        help_text="Order this column will appear in worklist export.",
                        null=True,
                        unique=True,
                        verbose_name="Ordering",
                    ),
                ),
                (
                    "meta_type",
                    models.ForeignKey(
                        blank=True,
                        help_text="Type of Metadata in this column.",
                        null=True,
                        on_delete=PROTECT,
                        to="main.MetadataType",
                        verbose_name="Metadata Type",
                    ),
                ),
            ],
            options={"db_table": "worklist_column"},
        ),
        migrations.CreateModel(
            name="Assay",
            fields=[
                (
                    "object_ref",
                    models.OneToOneField(
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        related_name="+",
                        serialize=False,
                        to="main.EDDObject",
                    ),
                ),
                (
                    "experimenter",
                    models.ForeignKey(
                        blank=True,
                        help_text="EDD User that set up the experimental conditions of this Assay.",
                        null=True,
                        on_delete=PROTECT,
                        related_name="assay_experimenter_set",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Experimenter",
                    ),
                ),
            ],
            options={"db_table": "assay"},
            bases=("main.eddobject",),
        ),
        migrations.CreateModel(
            name="CarbonSource",
            fields=[
                (
                    "object_ref",
                    models.OneToOneField(
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        related_name="+",
                        serialize=False,
                        to="main.EDDObject",
                    ),
                ),
                (
                    "labeling",
                    models.TextField(
                        help_text="Description of labeling isotopes in this Carbon Source.",
                        verbose_name="Labeling",
                    ),
                ),
                (
                    "volume",
                    models.DecimalField(
                        decimal_places=5,
                        help_text="Volume of solution added as a Carbon Source.",
                        max_digits=16,
                        verbose_name="Volume",
                    ),
                ),
            ],
            options={"db_table": "carbon_source"},
            bases=("main.eddobject",),
        ),
        migrations.CreateModel(
            name="GeneIdentifier",
            fields=[
                (
                    "measurementtype_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="main.MeasurementType",
                    ),
                ),
                (
                    "location_in_genome",
                    models.TextField(
                        blank=True,
                        help_text="Location of this Gene in the organism genome.",
                        null=True,
                        verbose_name="Location",
                    ),
                ),
                (
                    "positive_strand",
                    models.BooleanField(
                        default=True,
                        help_text="Flag indicating if transcript is positive (sense).",
                        verbose_name="Positive",
                    ),
                ),
                (
                    "location_start",
                    models.IntegerField(
                        blank=True,
                        help_text="Offset location for gene start.",
                        null=True,
                        verbose_name="Start",
                    ),
                ),
                (
                    "location_end",
                    models.IntegerField(
                        blank=True,
                        help_text="Offset location for gene end.",
                        null=True,
                        verbose_name="End",
                    ),
                ),
                (
                    "gene_length",
                    models.IntegerField(
                        blank=True,
                        help_text="Length of the gene nucleotides.",
                        null=True,
                        verbose_name="Length",
                    ),
                ),
            ],
            options={"db_table": "gene_identifier"},
            bases=("main.measurementtype",),
        ),
        migrations.CreateModel(
            name="Line",
            fields=[
                (
                    "control",
                    models.BooleanField(
                        default=False,
                        help_text="Flag indicating whether the sample for this Line is a control.",
                        verbose_name="Control",
                    ),
                ),
                (
                    "object_ref",
                    models.OneToOneField(
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        related_name="+",
                        serialize=False,
                        to="main.EDDObject",
                    ),
                ),
                (
                    "contact_extra",
                    models.TextField(
                        help_text="Additional field for contact information about this Line (e.g. contact is not a User of EDD).",
                        verbose_name="Contact (extra)",
                    ),
                ),
                (
                    "carbon_source",
                    models.ManyToManyField(
                        blank=True,
                        db_table="line_carbon_source",
                        help_text="Carbon source(s) used in this Line.",
                        to="main.CarbonSource",
                        verbose_name="Carbon Source(s)",
                    ),
                ),
                (
                    "contact",
                    models.ForeignKey(
                        blank=True,
                        help_text="EDD User to contact about this Line.",
                        null=True,
                        on_delete=PROTECT,
                        related_name="line_contact_set",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Contact",
                    ),
                ),
                (
                    "experimenter",
                    models.ForeignKey(
                        blank=True,
                        help_text="EDD User that set up the experimental conditions of this Line.",
                        null=True,
                        on_delete=PROTECT,
                        related_name="line_experimenter_set",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Experimenter",
                    ),
                ),
            ],
            options={"db_table": "line"},
            bases=("main.eddobject",),
        ),
        migrations.CreateModel(
            name="Metabolite",
            fields=[
                (
                    "measurementtype_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="main.MeasurementType",
                    ),
                ),
                (
                    "charge",
                    models.IntegerField(
                        help_text="The charge of this molecule.", verbose_name="Charge"
                    ),
                ),
                (
                    "carbon_count",
                    models.IntegerField(
                        help_text="Count of carbons present in this molecule.",
                        verbose_name="Carbon Count",
                    ),
                ),
                (
                    "molar_mass",
                    models.DecimalField(
                        decimal_places=5,
                        help_text="Molar mass of this molecule.",
                        max_digits=16,
                        verbose_name="Molar Mass",
                    ),
                ),
                (
                    "molecular_formula",
                    models.TextField(
                        help_text="Formula string defining this molecule.",
                        verbose_name="Formula",
                    ),
                ),
                (
                    "tags",
                    fields.ArrayField(
                        base_field=edd.fields.VarCharField(),
                        default=[],
                        help_text="List of tags for classifying this molecule.",
                        size=None,
                        verbose_name="Tags",
                    ),
                ),
            ],
            options={"db_table": "metabolite"},
            bases=("main.measurementtype",),
        ),
        migrations.CreateModel(
            name="Phosphor",
            fields=[
                (
                    "measurementtype_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="main.MeasurementType",
                    ),
                ),
                (
                    "excitation_wavelength",
                    models.DecimalField(
                        blank=True,
                        decimal_places=5,
                        help_text="Excitation wavelength for the material.",
                        max_digits=16,
                        null=True,
                        verbose_name="Excitation",
                    ),
                ),
                (
                    "emission_wavelength",
                    models.DecimalField(
                        blank=True,
                        decimal_places=5,
                        help_text="Emission wavelength for the material.",
                        max_digits=16,
                        null=True,
                        verbose_name="Emission",
                    ),
                ),
            ],
            options={"db_table": "phosphor_type"},
            bases=("main.measurementtype",),
        ),
        migrations.CreateModel(
            name="ProteinIdentifier",
            fields=[
                (
                    "measurementtype_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="main.MeasurementType",
                    ),
                ),
                (
                    "accession_id",
                    edd.fields.VarCharField(
                        blank=True,
                        help_text="Accession ID for protein characterized in e.g. UniProt.",
                        null=True,
                        verbose_name="Accession ID",
                    ),
                ),
                (
                    "length",
                    models.IntegerField(
                        blank=True,
                        help_text="sequence length",
                        null=True,
                        verbose_name="Length",
                    ),
                ),
                (
                    "mass",
                    models.DecimalField(
                        blank=True,
                        decimal_places=5,
                        help_text="of unprocessed protein, in Daltons",
                        max_digits=16,
                        null=True,
                        verbose_name="Mass",
                    ),
                ),
            ],
            options={"db_table": "protein_identifier"},
            bases=("main.measurementtype",),
        ),
        migrations.CreateModel(
            name="Protocol",
            fields=[
                (
                    "object_ref",
                    models.OneToOneField(
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        related_name="+",
                        serialize=False,
                        to="main.EDDObject",
                    ),
                ),
                (
                    "categorization",
                    models.CharField(
                        choices=[
                            ("NA", "None"),
                            ("OD", "Optical Density"),
                            ("HPLC", "HPLC"),
                            ("LCMS", "LCMS"),
                            ("RAMOS", "RAMOS"),
                            ("TPOMICS", "Transcriptomics / Proteomics"),
                        ],
                        default="NA",
                        help_text="Category of this Protocol.",
                        max_length=8,
                        verbose_name="Category",
                    ),
                ),
                (
                    "default_units",
                    models.ForeignKey(
                        blank=True,
                        help_text="Default units for values measured with this Protocol.",
                        null=True,
                        on_delete=SET_NULL,
                        related_name="protocol_set",
                        to="main.MeasurementUnit",
                        verbose_name="Default Units",
                    ),
                ),
                (
                    "owned_by",
                    models.ForeignKey(
                        help_text="Owner / maintainer of this Protocol",
                        on_delete=PROTECT,
                        related_name="protocol_set",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Owner",
                    ),
                ),
                (
                    "variant_of",
                    models.ForeignKey(
                        blank=True,
                        help_text="Link to another original Protocol used as basis for this Protocol.",
                        null=True,
                        on_delete=PROTECT,
                        related_name="derived_set",
                        to="main.Protocol",
                        verbose_name="Variant of Protocol",
                    ),
                ),
            ],
            options={"db_table": "protocol"},
            bases=("main.eddobject",),
        ),
        migrations.CreateModel(
            name="SBMLTemplate",
            fields=[
                (
                    "object_ref",
                    models.OneToOneField(
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        related_name="+",
                        serialize=False,
                        to="main.EDDObject",
                    ),
                ),
                (
                    "biomass_calculation",
                    models.DecimalField(
                        decimal_places=5,
                        default=-1,
                        help_text="The calculated multiplier converting OD to weight of biomass.",
                        max_digits=16,
                        verbose_name="Biomass Factor",
                    ),
                ),
                (
                    "biomass_calculation_info",
                    models.TextField(
                        default="",
                        help_text="Additional information on biomass calculation.",
                        verbose_name="Biomass Calculation",
                    ),
                ),
                (
                    "biomass_exchange_name",
                    models.TextField(
                        help_text="The reaction name in the model for Biomass.",
                        verbose_name="Biomass Reaction",
                    ),
                ),
            ],
            options={"db_table": "sbml_template"},
            bases=("main.eddobject",),
        ),
        migrations.CreateModel(
            name="Strain",
            fields=[
                (
                    "object_ref",
                    models.OneToOneField(
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        related_name="+",
                        serialize=False,
                        to="main.EDDObject",
                    ),
                ),
                (
                    "registry_id",
                    models.UUIDField(
                        blank=True,
                        help_text="The unique ID of this strain in the ICE Registry.",
                        null=True,
                        verbose_name="Registry UUID",
                    ),
                ),
                (
                    "registry_url",
                    models.URLField(
                        blank=True,
                        help_text="The URL of this strain in the ICE Registry.",
                        max_length=255,
                        null=True,
                        verbose_name="Registry URL",
                    ),
                ),
            ],
            options={"db_table": "strain"},
            bases=("main.eddobject",),
        ),
        migrations.CreateModel(
            name="Study",
            fields=[
                (
                    "object_ref",
                    models.OneToOneField(
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        related_name="+",
                        serialize=False,
                        to="main.EDDObject",
                    ),
                ),
                (
                    "contact_extra",
                    models.TextField(
                        help_text="Additional field for contact information about this study (e.g. contact is not a User of EDD).",
                        verbose_name="Contact (extra)",
                    ),
                ),
                (
                    "slug",
                    models.SlugField(
                        help_text="Slug text used in links to this Study.",
                        null=True,
                        unique=True,
                        verbose_name="Slug",
                    ),
                ),
                (
                    "contact",
                    models.ForeignKey(
                        blank=True,
                        help_text="EDD User to contact about this study.",
                        null=True,
                        on_delete=PROTECT,
                        related_name="contact_study_set",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Contact",
                    ),
                ),
                (
                    "metabolic_map",
                    models.ForeignKey(
                        blank=True,
                        help_text="Metabolic map used by default in this Study.",
                        null=True,
                        on_delete=SET_NULL,
                        to="main.SBMLTemplate",
                        verbose_name="Metabolic Map",
                    ),
                ),
                (
                    "protocols",
                    models.ManyToManyField(
                        blank=True,
                        db_table="study_protocol",
                        help_text="Protocols planned for use in this Study.",
                        to="main.Protocol",
                        verbose_name="Protocols",
                    ),
                ),
            ],
            options={"db_table": "study", "verbose_name_plural": "Studies"},
            bases=("main.eddobject",),
        ),
        migrations.CreateModel(
            name="WorklistTemplate",
            fields=[
                (
                    "eddobject_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="main.EDDObject",
                    ),
                ),
                (
                    "protocol",
                    models.ForeignKey(
                        help_text="Default protocol for this Template.",
                        on_delete=PROTECT,
                        to="main.Protocol",
                        verbose_name="Protocol",
                    ),
                ),
            ],
            options={"db_table": "worklist_template"},
            bases=("main.eddobject",),
        ),
        migrations.AddField(
            model_name="metabolitespecies",
            name="measurement_type",
            field=models.ForeignKey(
                blank=True,
                help_text="Mesurement type linked to this species in the model.",
                null=True,
                on_delete=CASCADE,
                to="main.MeasurementType",
                verbose_name="Measurement Type",
            ),
        ),
        migrations.AddField(
            model_name="metaboliteexchange",
            name="measurement_type",
            field=models.ForeignKey(
                blank=True,
                help_text="Measurement type linked to this exchange reaction in the model.",
                null=True,
                on_delete=CASCADE,
                to="main.MeasurementType",
                verbose_name="Measurement Type",
            ),
        ),
        migrations.AddField(
            model_name="measurementvalue",
            name="updated",
            field=models.ForeignKey(
                help_text="The Update triggering the setting of this point.",
                on_delete=PROTECT,
                to="main.Update",
                verbose_name="Updated",
            ),
        ),
        migrations.AddField(
            model_name="measurementtype",
            name="type_source",
            field=models.ForeignKey(
                blank=True,
                help_text="Datasource used for characterizing this Measurement Type.",
                null=True,
                on_delete=PROTECT,
                to="main.Datasource",
                verbose_name="Datasource",
            ),
        ),
        migrations.AddField(
            model_name="measurement",
            name="measurement_type",
            field=models.ForeignKey(
                help_text="The type of item measured for this Measurement.",
                on_delete=PROTECT,
                to="main.MeasurementType",
                verbose_name="Type",
            ),
        ),
        migrations.AddField(
            model_name="measurement",
            name="update_ref",
            field=models.ForeignKey(
                help_text="The Update triggering the setting of this Measurement.",
                on_delete=PROTECT,
                to="main.Update",
                verbose_name="Updated",
            ),
        ),
        migrations.AddField(
            model_name="measurement",
            name="x_units",
            field=models.ForeignKey(
                help_text="The units of the X-axis for this Measurement.",
                on_delete=PROTECT,
                related_name="+",
                to="main.MeasurementUnit",
                verbose_name="X Units",
            ),
        ),
        migrations.AddField(
            model_name="measurement",
            name="y_units",
            field=models.ForeignKey(
                help_text="The units of the Y-axis for this Measurement.",
                on_delete=PROTECT,
                related_name="+",
                to="main.MeasurementUnit",
                verbose_name="Y Units",
            ),
        ),
        migrations.AddField(
            model_name="eddobject",
            name="created",
            field=models.ForeignKey(
                editable=False,
                help_text="Update used to create this object.",
                on_delete=PROTECT,
                related_name="object_created",
                to="main.Update",
                verbose_name="Created",
            ),
        ),
        migrations.AddField(
            model_name="eddobject",
            name="updated",
            field=models.ForeignKey(
                editable=False,
                help_text="Update used to last modify this object.",
                on_delete=PROTECT,
                related_name="object_updated",
                to="main.Update",
                verbose_name="Last Modified",
            ),
        ),
        migrations.AddField(
            model_name="eddobject",
            name="updates",
            field=models.ManyToManyField(
                db_table="edd_object_update",
                help_text="List of Update objects logging changes to this object.",
                related_name="_eddobject_updates_+",
                to="main.Update",
                verbose_name="Updates",
            ),
        ),
        migrations.AddField(
            model_name="datasource",
            name="created",
            field=models.ForeignKey(
                editable=False,
                help_text="Update object logging the creation of this Datasource.",
                on_delete=PROTECT,
                related_name="datasource",
                to="main.Update",
                verbose_name="Created",
            ),
        ),
        migrations.AddField(
            model_name="comment",
            name="created",
            field=models.ForeignKey(
                help_text="Update object logging the creation of this Comment.",
                on_delete=PROTECT,
                to="main.Update",
                verbose_name="Created",
            ),
        ),
        migrations.AddField(
            model_name="comment",
            name="object_ref",
            field=models.ForeignKey(
                on_delete=CASCADE, related_name="comments", to="main.EDDObject"
            ),
        ),
        migrations.AddField(
            model_name="attachment",
            name="created",
            field=models.ForeignKey(
                help_text="Update used to create the attachment.",
                on_delete=PROTECT,
                to="main.Update",
                verbose_name="Created",
            ),
        ),
        migrations.AddField(
            model_name="attachment",
            name="object_ref",
            field=models.ForeignKey(
                on_delete=CASCADE, related_name="files", to="main.EDDObject"
            ),
        ),
        migrations.AddField(
            model_name="worklistcolumn",
            name="template",
            field=models.ForeignKey(
                help_text="Parent Worklist Template for this column.",
                on_delete=CASCADE,
                to="main.WorklistTemplate",
                verbose_name="Template",
            ),
        ),
        migrations.AddField(
            model_name="userpermission",
            name="study",
            field=models.ForeignKey(
                help_text="Study this permission applies to.",
                on_delete=CASCADE,
                to="main.Study",
                verbose_name="Study",
            ),
        ),
        migrations.AddField(
            model_name="sbmltemplate",
            name="sbml_file",
            field=models.ForeignKey(
                blank=True,
                help_text="The Attachment containing the SBML model file.",
                null=True,
                on_delete=PROTECT,
                to="main.Attachment",
                verbose_name="SBML Model",
            ),
        ),
        migrations.AddField(
            model_name="phosphor",
            name="reference_type",
            field=models.ForeignKey(
                blank=True,
                help_text="Link to another Measurement Type used as a reference for this type.",
                null=True,
                on_delete=PROTECT,
                related_name="phosphor_set",
                to="main.MeasurementType",
                verbose_name="Reference",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="metadatatype", unique_together={("type_name", "for_context")}
        ),
        migrations.AddField(
            model_name="metabolitespecies",
            name="sbml_template",
            field=models.ForeignKey(
                help_text="The SBML Model defining this species link to a Measurement Type.",
                on_delete=PROTECT,
                to="main.SBMLTemplate",
                verbose_name="SBML Model",
            ),
        ),
        migrations.AddField(
            model_name="metaboliteexchange",
            name="sbml_template",
            field=models.ForeignKey(
                help_text="The SBML Model containing this exchange reaction.",
                on_delete=CASCADE,
                to="main.SBMLTemplate",
                verbose_name="SBML Model",
            ),
        ),
        migrations.AddField(
            model_name="measurement",
            name="assay",
            field=models.ForeignKey(
                help_text="The Assay creating this Measurement.",
                on_delete=CASCADE,
                to="main.Assay",
                verbose_name="Assay",
            ),
        ),
        migrations.AddField(
            model_name="line",
            name="protocols",
            field=models.ManyToManyField(
                help_text="Protocol(s) used to Assay this Line.",
                through="main.Assay",
                to="main.Protocol",
                verbose_name="Protocol(s)",
            ),
        ),
        migrations.AddField(
            model_name="line",
            name="replicate",
            field=models.ForeignKey(
                blank=True,
                help_text="Indicates that this Line is a (biological) replicate of another Line.",
                null=True,
                on_delete=PROTECT,
                to="main.Line",
                verbose_name="Replicate",
            ),
        ),
        migrations.AddField(
            model_name="line",
            name="strains",
            field=models.ManyToManyField(
                blank=True,
                db_table="line_strain",
                help_text="Strain(s) used in this Line.",
                to="main.Strain",
                verbose_name="Strain(s)",
            ),
        ),
        migrations.AddField(
            model_name="line",
            name="study",
            field=models.ForeignKey(
                help_text="The Study containing this Line.",
                on_delete=CASCADE,
                to="main.Study",
                verbose_name="Study",
            ),
        ),
        migrations.AddField(
            model_name="grouppermission",
            name="study",
            field=models.ForeignKey(
                help_text="Study this permission applies to.",
                on_delete=CASCADE,
                to="main.Study",
                verbose_name="Study",
            ),
        ),
        migrations.AddField(
            model_name="everyonepermission",
            name="study",
            field=models.ForeignKey(
                help_text="Study this permission applies to.",
                on_delete=CASCADE,
                to="main.Study",
                verbose_name="Study",
            ),
        ),
        migrations.AddField(
            model_name="assay",
            name="line",
            field=models.ForeignKey(
                help_text="The Line used for this Assay.",
                on_delete=CASCADE,
                to="main.Line",
                verbose_name="Line",
            ),
        ),
        migrations.AddField(
            model_name="assay",
            name="measurement_types",
            field=models.ManyToManyField(
                help_text="The Measurement Types contained in this Assay.",
                through="main.Measurement",
                to="main.MeasurementType",
                verbose_name="Measurement Types",
            ),
        ),
        migrations.AddField(
            model_name="assay",
            name="protocol",
            field=models.ForeignKey(
                help_text="The Protocol used to create this Assay.",
                on_delete=PROTECT,
                to="main.Protocol",
                verbose_name="Protocol",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="metabolitespecies",
            unique_together={
                ("sbml_template", "species"),
                ("sbml_template", "measurement_type"),
            },
        ),
        migrations.AlterIndexTogether(
            name="metabolitespecies", index_together={("sbml_template", "species")}
        ),
        migrations.AlterUniqueTogether(
            name="metaboliteexchange",
            unique_together={
                ("sbml_template", "exchange_name"),
                ("sbml_template", "measurement_type"),
            },
        ),
        migrations.AlterIndexTogether(
            name="metaboliteexchange",
            index_together={
                ("sbml_template", "exchange_name"),
                ("sbml_template", "reactant_name"),
            },
        ),
        # PostgreSQL-specific bits here!
        # Django will attempt to assign a single UUID as default in migration, even with a
        #   callable. Instead, directly use Postgres support for UUID function.
        migrations.RunSQL(
            sql='ALTER TABLE "edd_object" ALTER COLUMN "uuid" SET DEFAULT uuid_generate_v4();',
            reverse_sql='ALTER TABLE "edd_object" ALTER COLUMN "uuid" DROP DEFAULT;',
        ),
        migrations.RunSQL(
            sql='ALTER TABLE "measurement_type" ALTER COLUMN "uuid" SET DEFAULT uuid_generate_v4();',
            reverse_sql='ALTER TABLE "measurement_type" ALTER COLUMN "uuid" DROP DEFAULT;',
        ),
        migrations.RunSQL(
            sql='ALTER TABLE "metadata_type" ALTER COLUMN "uuid" SET DEFAULT uuid_generate_v4();',
            reverse_sql='ALTER TABLE "metadata_type" ALTER COLUMN "uuid" DROP DEFAULT;',
        ),
        # Create partial unique index on MetadataType.type_i18n
        migrations.RunSQL(
            sql="CREATE UNIQUE INDEX metadata_type_partial_unique_i18n ON metadata_type(type_i18n) WHERE type_i18n IS NOT NULL;",
            reverse_sql="DROP INDEX metadata_type_partial_unique_i18n;",
        ),
    ]
