# Generated by Django 4.1.11 on 2023-09-08 19:43

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import releasemanager.models


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("sites", "0002_alter_domain_unique"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Package",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100, unique=True)),
                ("package_key", models.CharField(max_length=100, unique=True)),
                ("description", models.TextField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name="Release",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "active",
                    models.BooleanField(
                        default=False,
                        help_text="Is this release active for production?",
                    ),
                ),
                ("version", models.CharField(max_length=20)),
                ("release_date", models.DateTimeField()),
                (
                    "files",
                    models.JSONField(
                        blank=True,
                        default=releasemanager.models.default_release_paths,
                        help_text="Nested type information for this release",
                        null=True,
                    ),
                ),
                (
                    "package",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="releases",
                        to="releasemanager.package",
                    ),
                ),
            ],
            options={
                "ordering": ["-release_date"],
                "unique_together": {("package", "version")},
            },
        ),
        migrations.CreateModel(
            name="ReleaseGroup",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100, unique=True)),
                ("description", models.TextField(blank=True, null=True)),
                ("active", models.BooleanField(default=False)),
                (
                    "members",
                    models.ManyToManyField(
                        blank=True,
                        related_name="release_groups",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "releases",
                    models.ManyToManyField(
                        blank=True,
                        related_name="release_groups",
                        to="releasemanager.release",
                    ),
                ),
                (
                    "sites",
                    models.ManyToManyField(
                        blank=True, related_name="releases", to="sites.site"
                    ),
                ),
            ],
        ),
    ]
