# Generated by Django 4.1.13 on 2024-06-07 14:19

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),
        ("auth", "0012_alter_user_first_name_max_length"),
    ]

    operations = [
        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?",
                    ),
                ),
                (
                    "status",
                    models.IntegerField(
                        choices=[
                            (1, "Development"),
                            (10, "Testing"),
                            (20, "Hold"),
                            (30, "Production"),
                            (40, "Deprecated"),
                        ],
                        default=1,
                        help_text="Current status of the release",
                    ),
                ),
                ("name", models.CharField(max_length=20)),
                ("release_date", models.DateTimeField()),
                (
                    "deprecation_date",
                    models.DateTimeField(
                        blank=True,
                        help_text="When the release is scheduled to be deprecated",
                        null=True,
                    ),
                ),
                (
                    "release_notes",
                    models.TextField(
                        blank=True,
                        help_text="Detailed notes about what is new, changed, or fixed",
                    ),
                ),
                (
                    "package",
                    models.CharField(
                        choices=[("basic", "Basic"), ("advanced", "Advanced")],
                        max_length=100,
                    ),
                ),
                (
                    "files",
                    models.JSONField(
                        blank=True,
                        default=releasemanager.models.default_release_paths,
                        help_text="Nested type information for this release",
                        null=True,
                    ),
                ),
                (
                    "signature",
                    models.CharField(
                        blank=True,
                        help_text="Digital signature for release integrity",
                        max_length=256,
                        null=True,
                    ),
                ),
                (
                    "groups",
                    models.ManyToManyField(
                        blank=True,
                        help_text="User groups that can access this release",
                        to="auth.group",
                    ),
                ),
                (
                    "released_by",
                    models.ForeignKey(
                        blank=True,
                        help_text="User who created the release",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "sites",
                    models.ManyToManyField(
                        blank=True,
                        help_text="Sites where this release is isolated to.  If empty, it is available globally.",
                        to="sites.site",
                    ),
                ),
            ],
            options={
                "ordering": ["-release_date"],
                "permissions": [("can_test_releases", "Can access testing releases")],
                "unique_together": {("package", "name")},
            },
        ),
    ]
