# Generated by Django 5.2.12 on 2026-03-22 16:07

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


class Migration(migrations.Migration):

    dependencies = [
        ('account', '0035_setting'),
    ]

    operations = [
        migrations.CreateModel(
            name='BouncerDevice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('muid', models.CharField(db_index=True, max_length=64, unique=True)),
                ('duid', models.CharField(blank=True, db_index=True, default='', max_length=255)),
                ('msid', models.CharField(blank=True, db_index=True, default='', max_length=64)),
                ('fingerprint_id', models.CharField(blank=True, db_index=True, max_length=64, null=True)),
                ('risk_tier', models.CharField(choices=[('unknown', 'Unknown'), ('low', 'Low'), ('medium', 'Medium'), ('high', 'High'), ('blocked', 'Blocked')], db_index=True, default='unknown', max_length=16)),
                ('event_count', models.IntegerField(default=0)),
                ('block_count', models.IntegerField(default=0)),
                ('last_seen_ip', models.GenericIPAddressField(blank=True, null=True)),
                ('linked_muids', models.JSONField(blank=True, default=list)),
                ('first_seen', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('last_seen', models.DateTimeField(auto_now=True, db_index=True)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('modified', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['-last_seen'],
            },
            bases=(models.Model, mojo.models.rest.MojoModel),
        ),
        migrations.AddField(
            model_name='userdevice',
            name='muid',
            field=models.CharField(blank=True, db_index=True, default='', max_length=64),
        ),
        migrations.CreateModel(
            name='BotSignature',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('sig_type', models.CharField(choices=[('ip', 'IP Address'), ('subnet_24', 'Subnet /24'), ('subnet_16', 'Subnet /16'), ('user_agent', 'User Agent'), ('fingerprint', 'Browser Fingerprint'), ('signal_set', 'Signal Set (Campaign)')], db_index=True, max_length=16)),
                ('value', models.CharField(db_index=True, max_length=512)),
                ('source', models.CharField(default='auto', max_length=8)),
                ('confidence', models.IntegerField(default=0)),
                ('hit_count', models.IntegerField(default=0)),
                ('block_count', models.IntegerField(default=0)),
                ('expires_at', models.DateTimeField(blank=True, db_index=True, null=True)),
                ('is_active', models.BooleanField(db_index=True, default=True)),
                ('notes', models.TextField(blank=True, default='')),
                ('created', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('modified', models.DateTimeField(auto_now=True, db_index=True)),
            ],
            options={
                'ordering': ['-modified'],
                'unique_together': {('sig_type', 'value')},
            },
            bases=(models.Model, mojo.models.rest.MojoModel),
        ),
        migrations.CreateModel(
            name='BouncerSignal',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('muid', models.CharField(blank=True, db_index=True, default='', max_length=64)),
                ('duid', models.CharField(blank=True, db_index=True, default='', max_length=255)),
                ('msid', models.CharField(blank=True, db_index=True, default='', max_length=64)),
                ('mtab', models.CharField(blank=True, db_index=True, default='', max_length=64)),
                ('session_id', models.CharField(blank=True, db_index=True, default='', max_length=64)),
                ('stage', models.CharField(choices=[('assess', 'Assess'), ('submit', 'Submit'), ('event', 'Event')], db_index=True, default='assess', max_length=16)),
                ('ip_address', models.GenericIPAddressField(db_index=True)),
                ('page_type', models.CharField(db_index=True, default='login', max_length=32)),
                ('raw_signals', models.JSONField(blank=True, default=dict)),
                ('server_signals', models.JSONField(blank=True, default=dict)),
                ('risk_score', models.IntegerField(db_index=True, default=0)),
                ('decision', models.CharField(choices=[('allow', 'Allow'), ('monitor', 'Monitor'), ('block', 'Block'), ('log', 'Log')], db_index=True, default='allow', max_length=16)),
                ('triggered_signals', models.JSONField(blank=True, default=list)),
                ('token_nonce', models.CharField(blank=True, max_length=64, null=True)),
                ('created', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('device', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='signals', to='account.bouncerdevice')),
                ('geo_ip', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='account.geolocatedip')),
            ],
            options={
                'ordering': ['-created'],
            },
            bases=(models.Model, mojo.models.rest.MojoModel),
        ),
    ]
