# Generated by Django 4.2.24 on 2025-09-16 18:48

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='APIRateLimit',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('subscription_type', models.CharField(choices=[('free', 'Free'), ('paid', 'Paid'), ('premium', 'Premium')], max_length=20, unique=True)),
                ('requests_per_minute', models.IntegerField(default=60)),
                ('requests_per_hour', models.IntegerField(default=1000)),
                ('requests_per_day', models.IntegerField(default=10000)),
            ],
            options={
                'db_table': 'api_rate_limits',
            },
        ),
        migrations.CreateModel(
            name='SystemConfiguration',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('key', models.CharField(max_length=100, unique=True)),
                ('value', models.TextField()),
                ('description', models.TextField(blank=True)),
                ('is_encrypted', models.BooleanField(default=False)),
            ],
            options={
                'db_table': 'system_configuration',
            },
        ),
        migrations.CreateModel(
            name='AuditLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('action', models.CharField(max_length=100)),
                ('resource_type', models.CharField(max_length=50)),
                ('resource_id', models.CharField(blank=True, max_length=100)),
                ('details', models.JSONField(default=dict)),
                ('ip_address', models.GenericIPAddressField()),
                ('user_agent', models.TextField(blank=True)),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'audit_logs',
                'indexes': [models.Index(fields=['user', 'created_at'], name='audit_logs_user_id_fbfd51_idx'), models.Index(fields=['action', 'created_at'], name='audit_logs_action_391715_idx'), models.Index(fields=['resource_type', 'resource_id'], name='audit_logs_resourc_bda8a6_idx')],
            },
        ),
        migrations.CreateModel(
            name='APIUsage',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('endpoint', models.CharField(max_length=255)),
                ('method', models.CharField(max_length=10)),
                ('status_code', models.IntegerField()),
                ('response_time_ms', models.IntegerField()),
                ('ip_address', models.GenericIPAddressField()),
                ('user_agent', models.TextField(blank=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='api_usage', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'api_usage',
                'indexes': [models.Index(fields=['user', 'created_at'], name='api_usage_user_id_b7cc9a_idx'), models.Index(fields=['endpoint', 'created_at'], name='api_usage_endpoin_6aa3d0_idx')],
            },
        ),
    ]
