# Generated by Django 6.0 on 2026-03-22 00:17

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


class Migration(migrations.Migration):

    dependencies = [
        ('api', '0321_persistentagentwebsession_visibility_state'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='UserTrialEligibility',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('auto_status', models.CharField(choices=[('eligible', 'Eligible'), ('no_trial', 'No Trial'), ('review', 'Review')], default='eligible', max_length=16)),
                ('manual_action', models.CharField(choices=[('inherit', 'Automatic'), ('allow_trial', 'Allow Trial'), ('deny_trial', 'Deny Trial')], default='inherit', max_length=16)),
                ('reason_codes', models.JSONField(blank=True, default=list)),
                ('evidence_summary', models.JSONField(blank=True, default=dict)),
                ('evaluated_at', models.DateTimeField(blank=True, null=True)),
                ('reviewed_at', models.DateTimeField(blank=True, null=True)),
                ('review_note', models.TextField(blank=True, default='')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('reviewed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='trial_eligibility_reviews', to=settings.AUTH_USER_MODEL)),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='trial_eligibility', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'User trial eligibility',
                'verbose_name_plural': 'User trial eligibility',
            },
        ),
        migrations.CreateModel(
            name='UserIdentitySignal',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('signal_type', models.CharField(choices=[('fpjs_visitor_id', 'FPJS Visitor ID'), ('fpjs_request_id', 'FPJS Request ID'), ('fbp', 'Meta Browser ID'), ('ga_client_id', 'GA Client ID'), ('ip_exact', 'Exact IP'), ('ip_prefix', 'IP Prefix')], max_length=32)),
                ('signal_value', models.CharField(max_length=512)),
                ('first_seen_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('last_seen_at', models.DateTimeField(db_index=True, default=django.utils.timezone.now)),
                ('first_seen_source', models.CharField(blank=True, default='', max_length=32)),
                ('last_seen_source', models.CharField(blank=True, default='', max_length=32)),
                ('observation_count', models.PositiveIntegerField(default=1)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='identity_signals', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'User identity signal',
                'verbose_name_plural': 'User identity signals',
                'ordering': ['-last_seen_at', '-id'],
                'indexes': [models.Index(fields=['signal_type', 'signal_value'], name='identity_signal_lookup_idx'), models.Index(fields=['user', 'signal_type'], name='identity_signal_user_type_idx')],
                'constraints': [models.UniqueConstraint(fields=('user', 'signal_type', 'signal_value'), name='uniq_user_identity_signal')],
            },
        ),
    ]
