# Generated by Django 4.2.13 on 2024-07-19 10:53

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


class Migration(migrations.Migration):

    dependencies = [
        ("simple_certmanager", "0002_alter_certificate_private_key_and_more"),
        ("digid_eherkenning", "0010_remove_digidconfiguration_key_passphrase_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="ConfigCertificate",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "config_type",
                    models.CharField(
                        choices=[
                            ("digid_eherkenning.DigidConfiguration", "DigiD"),
                            (
                                "digid_eherkenning.EherkenningConfiguration",
                                "eHerkenning",
                            ),
                        ],
                        max_length=100,
                        verbose_name="config type",
                    ),
                ),
                (
                    "certificate",
                    models.ForeignKey(
                        help_text="Certificate that may be used by the specified configuration. The best matching candidate will automatically be selected by the configuration.",
                        limit_choices_to={"type": "key_pair"},
                        on_delete=django.db.models.deletion.PROTECT,
                        to="simple_certmanager.certificate",
                        verbose_name="certificate",
                    ),
                ),
            ],
            options={
                "verbose_name": "DigiD/eHerkenning certificate",
                "verbose_name_plural": "DigiD/eHerkenning certificates",
            },
        ),
        migrations.AddConstraint(
            model_name="configcertificate",
            constraint=models.UniqueConstraint(
                fields=("config_type", "certificate"),
                name="uniq_config_cert",
                violation_error_message="This configuration and certificate combination already exists.",
            ),
        ),
    ]
