# Generated by Django 5.1.6 on 2025-03-04 01:20

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

import allianceauth.framework.api.user


def create_permissions(apps, schema_editor) -> None:
    # Remnant of AAv0
    User = apps.get_model('auth', 'User')
    ContentType = apps.get_model('contenttypes', 'ContentType')
    Permission = apps.get_model('auth', 'Permission')
    ct = ContentType.objects.get_for_model(User)
    Permission.objects.get_or_create(codename="fleetactivitytracking", content_type=ct, name="fleetactivitytracking")
    Permission.objects.get_or_create(codename="fleetactivitytracking_statistics", content_type=ct, name="fleetactivitytracking_statistics")


def reverse(apps, schema_editor) -> None:
    pass


class Migration(migrations.Migration):

    replaces = [('fleetactivitytracking', '0001_initial'), ('fleetactivitytracking', '0002_auto_20160905_2220'), ('fleetactivitytracking', '0003_auto_20160906_2354'), ('fleetactivitytracking', '0004_make_strings_more_stringy'), ('fleetactivitytracking', '0005_remove_fat_name'), ('fleetactivitytracking', '0006_auto_20180803_0430'), ('fleetactivitytracking', '0007_sentinel_user')]

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('eveonline', '0019_v5squash'),
    ]

    operations = [
        migrations.CreateModel(
            name='Fatlink',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('fatdatetime', models.DateTimeField(default=django.utils.timezone.now)),
                ('duration', models.PositiveIntegerField()),
                ('fleet', models.CharField(max_length=254)),
                ('hash', models.CharField(max_length=254, unique=True)),
                ('creator', models.ForeignKey(on_delete=models.SET(allianceauth.framework.api.user.get_sentinel_user), to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'permissions': ()
            },
        ),
        migrations.CreateModel(
            name='Fat',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('system', models.CharField(max_length=30)),
                ('shiptype', models.CharField(max_length=100)),
                ('station', models.CharField(max_length=125)),
                ('character', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='eveonline.evecharacter')),
                ('fatlink', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fleetactivitytracking.fatlink')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'unique_together': {('character', 'fatlink')},
            },
        ),
        migrations.RunPython(create_permissions, reverse)
    ]
