# Generated by Django 5.2.4 on 2025-10-03 23:08

import core.fields
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0058_rfid_external_command"),
    ]

    operations = [
        migrations.CreateModel(
            name="OpenPayProfile",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("merchant_id", core.fields.SigilShortAutoField(max_length=100)),
                ("private_key", core.fields.SigilShortAutoField(max_length=255)),
                ("public_key", core.fields.SigilShortAutoField(max_length=255)),
                ("is_production", models.BooleanField(default=False)),
                (
                    "webhook_secret",
                    core.fields.SigilShortAutoField(blank=True, max_length=255),
                ),
                ("verified_on", models.DateTimeField(blank=True, null=True)),
                (
                    "verification_reference",
                    models.CharField(blank=True, editable=False, max_length=255),
                ),
                (
                    "group",
                    models.OneToOneField(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="core.securitygroup",
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "OpenPay Merchant",
                "verbose_name_plural": "OpenPay Merchants",
                "constraints": [
                    models.CheckConstraint(
                        condition=models.Q(
                            models.Q(("user__isnull", False), ("group__isnull", True)),
                            models.Q(("user__isnull", True), ("group__isnull", False)),
                            _connector="OR",
                        ),
                        name="openpayprofile_requires_owner",
                    )
                ],
            },
        ),
    ]
