# Generated by Django 5.0.6 on 2024-05-14 18:27

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

import lnschema_core.models
import lnschema_core.users


class Migration(migrations.Migration):
    dependencies = [
        ("lnschema_core", "0046_storage_instance_uid"),
    ]

    operations = [
        migrations.CreateModel(
            name="FeatureValue",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("value", models.JSONField()),
                ("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        default=lnschema_core.users.current_user_id,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="created_feature_sets",
                        to="lnschema_core.user",
                    ),
                ),
                (
                    "feature",
                    models.ForeignKey(
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lnschema_core.feature",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="ArtifactFeatureValue",
            fields=[
                ("id", models.BigAutoField(primary_key=True, serialize=False)),
                (
                    "artifact",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lnschema_core.artifact",
                    ),
                ),
                (
                    "feature_value",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lnschema_core.featurevalue",
                    ),
                ),
            ],
            options={
                "unique_together": {("artifact", "feature_value")},
            },
            bases=(models.Model, lnschema_core.models.LinkORM),
        ),
        migrations.AddField(
            model_name="artifact",
            name="feature_values",
            field=models.ManyToManyField(
                through="lnschema_core.ArtifactFeatureValue",
                to="lnschema_core.featurevalue",
            ),
        ),
        migrations.CreateModel(
            name="Param",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(db_index=True, max_length=100)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True, db_index=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="lnschema_core.user",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="ParamValue",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("value", models.JSONField()),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="lnschema_core.user",
                    ),
                ),
                (
                    "param",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lnschema_core.param",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="RunParamValue",
            fields=[
                ("id", models.BigAutoField(primary_key=True, serialize=False)),
                (
                    "param_value",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lnschema_core.paramvalue",
                    ),
                ),
                (
                    "run",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lnschema_core.run",
                    ),
                ),
            ],
            options={
                "unique_together": {("run", "param_value")},
            },
            bases=(models.Model, lnschema_core.models.LinkORM),
        ),
        migrations.AddField(
            model_name="run",
            name="param_values",
            field=models.ManyToManyField(
                related_name="runs",
                through="lnschema_core.RunParamValue",
                to="lnschema_core.paramvalue",
            ),
        ),
    ]
