# Generated by Django 6.0.3 on 2026-03-26 08:26

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='UserCertificate',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('fingerprint_sha256', models.CharField(db_index=True, help_text='SHA-256 fingerprint of the DER-encoded certificate.', max_length=64, unique=True, verbose_name='SHA-256 Fingerprint')),
                ('subject_dn', models.CharField(help_text='Certificate subject distinguished name (RFC 4514 format).', max_length=1024, verbose_name='Subject DN')),
                ('issuer_dn', models.CharField(help_text='Certificate issuer distinguished name (RFC 4514 format).', max_length=1024, verbose_name='Issuer DN')),
                ('serial_number', models.CharField(help_text='Certificate serial number in hexadecimal.', max_length=256, verbose_name='Serial Number')),
                ('common_name', models.CharField(blank=True, default='', help_text='Subject common name (CN).', max_length=256, verbose_name='Common Name')),
                ('organization', models.CharField(blank=True, default='', help_text='Subject organization (O).', max_length=256, verbose_name='Organization')),
                ('not_valid_before', models.DateTimeField(help_text='Certificate validity start date.', verbose_name='Not Valid Before')),
                ('not_valid_after', models.DateTimeField(help_text='Certificate validity end date.', verbose_name='Not Valid After')),
                ('certificate_pem', models.TextField(help_text='PEM-encoded X.509 certificate data.', verbose_name='Certificate PEM')),
                ('is_active', models.BooleanField(db_index=True, default=True, help_text='Whether this certificate is active for authentication.', verbose_name='Is Active')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('user', models.ForeignKey(help_text='The user this certificate belongs to.', on_delete=django.db.models.deletion.CASCADE, related_name='ecp_certificates', to=settings.AUTH_USER_MODEL, verbose_name='User')),
            ],
            options={
                'verbose_name': 'User Certificate',
                'verbose_name_plural': 'User Certificates',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['user', 'is_active'], name='idx_user_active_cert')],
            },
        ),
    ]
