# Generated by Django 6.0.4 on 2026-06-06 02:55

import apps.analytics.models
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Hit',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('event_type', models.CharField(choices=[('pageview', 'Pageview'), ('event', 'Event')], db_index=True, default='pageview', max_length=16)),
                ('event_name', models.CharField(blank=True, db_index=True, max_length=120)),
                ('path', models.CharField(blank=True, db_index=True, max_length=512)),
                ('hostname', models.CharField(blank=True, max_length=255)),
                ('title', models.CharField(blank=True, max_length=255)),
                ('ip_hash', models.CharField(blank=True, db_index=True, max_length=64)),
                ('visitor_hash', models.CharField(blank=True, db_index=True, max_length=64)),
                ('session_id', models.CharField(blank=True, db_index=True, max_length=64)),
                ('country', models.CharField(blank=True, db_index=True, max_length=64)),
                ('country_code', models.CharField(blank=True, db_index=True, max_length=2)),
                ('device', models.CharField(blank=True, db_index=True, max_length=32)),
                ('os', models.CharField(blank=True, max_length=64)),
                ('browser', models.CharField(blank=True, max_length=64)),
                ('referer', models.CharField(blank=True, max_length=1024)),
                ('referer_host', models.CharField(blank=True, db_index=True, max_length=255)),
                ('utm_source', models.CharField(blank=True, db_index=True, max_length=128)),
                ('utm_medium', models.CharField(blank=True, max_length=128)),
                ('utm_campaign', models.CharField(blank=True, db_index=True, max_length=128)),
                ('utm_term', models.CharField(blank=True, max_length=128)),
                ('utm_content', models.CharField(blank=True, max_length=128)),
                ('props', models.JSONField(blank=True, default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
            ],
            options={
                'db_table': 'analytics_hits',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Site',
            fields=[
                ('id', models.UUIDField(default=apps.analytics.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=120)),
                ('domain', models.CharField(help_text='Primary hostname, e.g. example.com', max_length=255)),
                ('public_key', models.CharField(db_index=True, default=apps.analytics.models.gen_public_key, max_length=32, unique=True)),
                ('is_active', models.BooleanField(default=True)),
                ('favicon_url', models.URLField(blank=True, max_length=512)),
                ('title', models.CharField(blank=True, max_length=255)),
                ('description', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': 'Analytics Site',
                'verbose_name_plural': 'Analytics Sites',
                'db_table': 'analytics_sites',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='AccessLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('resource_type', models.CharField(choices=[('shorten_url', 'Shorten URL'), ('publication', 'Publication'), ('event', 'Event'), ('other', 'Other')], default='other', max_length=32)),
                ('resource_id', models.CharField(blank=True, db_index=True, max_length=64)),
                ('resource_slug', models.CharField(blank=True, db_index=True, max_length=255)),
                ('path', models.CharField(max_length=512)),
                ('method', models.CharField(default='GET', max_length=8)),
                ('status_code', models.PositiveSmallIntegerField(default=200)),
                ('response_time_ms', models.PositiveIntegerField(default=0)),
                ('ip_hash', models.CharField(db_index=True, max_length=64)),
                ('visitor_hash', models.CharField(db_index=True, max_length=64)),
                ('country', models.CharField(blank=True, db_index=True, max_length=64)),
                ('country_code', models.CharField(blank=True, db_index=True, max_length=2)),
                ('device', models.CharField(blank=True, db_index=True, max_length=32)),
                ('os', models.CharField(blank=True, max_length=64)),
                ('browser', models.CharField(blank=True, max_length=64)),
                ('user_agent', models.CharField(blank=True, max_length=512)),
                ('referer', models.CharField(blank=True, max_length=1024)),
                ('referer_host', models.CharField(blank=True, db_index=True, max_length=255)),
                ('tags', models.JSONField(blank=True, default=list)),
                ('utm_source', models.CharField(blank=True, db_index=True, max_length=128)),
                ('utm_medium', models.CharField(blank=True, max_length=128)),
                ('utm_campaign', models.CharField(blank=True, db_index=True, max_length=128)),
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
            ],
            options={
                'db_table': 'analytics_access_logs',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['resource_type', 'resource_id'], name='analytics_a_resourc_12b66b_idx'), models.Index(fields=['resource_type', 'created_at'], name='analytics_a_resourc_c31e43_idx')],
            },
        ),
    ]
