# Generated by Django 4.2.16 on 2026-03-24 12:28

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='ChronographAnalysis',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=150, verbose_name='name')),
                ('date', models.DateField(verbose_name='date')),
                ('notes', models.TextField(blank=True, verbose_name='notes')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='updated at')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='chronograph_analyses', to=settings.AUTH_USER_MODEL, verbose_name='user')),
            ],
            options={
                'verbose_name': 'chronograph analysis',
                'verbose_name_plural': 'chronograph analyses',
                'ordering': ['-date', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='ResultPicture',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('image', models.ImageField(upload_to='result_pictures/', verbose_name='image')),
                ('description', models.CharField(blank=True, max_length=255, verbose_name='description')),
                ('group_size_mm', models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True, verbose_name='group size (mm)')),
                ('group_size_moa', models.DecimalField(blank=True, decimal_places=3, max_digits=7, null=True, verbose_name='group size (MOA)')),
                ('elevation_offset_mm', models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True, verbose_name='elevation offset (mm)')),
                ('elevation_offset_moa', models.DecimalField(blank=True, decimal_places=3, max_digits=7, null=True, verbose_name='elevation offset (MOA)')),
                ('windage_offset_mm', models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True, verbose_name='windage offset (mm)')),
                ('windage_offset_moa', models.DecimalField(blank=True, decimal_places=3, max_digits=7, null=True, verbose_name='windage offset (MOA)')),
                ('mean_radius_mm', models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True, verbose_name='mean radius (mm)')),
                ('mean_radius_moa', models.DecimalField(blank=True, decimal_places=3, max_digits=7, null=True, verbose_name='mean radius (MOA)')),
                ('uploaded_at', models.DateTimeField(auto_now_add=True, verbose_name='uploaded at')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_pictures', to=settings.AUTH_USER_MODEL, verbose_name='user')),
            ],
            options={
                'verbose_name': 'result picture',
                'verbose_name_plural': 'result pictures',
                'ordering': ['-uploaded_at'],
            },
        ),
        migrations.CreateModel(
            name='ShotGroup',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('label', models.CharField(max_length=100, verbose_name='label')),
                ('distance_m', models.DecimalField(blank=True, decimal_places=1, max_digits=7, null=True, verbose_name='distance (m)')),
                ('order', models.PositiveSmallIntegerField(default=0, verbose_name='order')),
                ('notes', models.TextField(blank=True, verbose_name='notes')),
                ('analysis', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shot_groups', to='tools.chronographanalysis', verbose_name='analysis')),
                ('result_picture', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='shot_group', to='tools.resultpicture', verbose_name='result picture')),
            ],
            options={
                'verbose_name': 'shot group',
                'verbose_name_plural': 'shot groups',
                'ordering': ['order', 'id'],
            },
        ),
        migrations.CreateModel(
            name='Shot',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('shot_number', models.PositiveSmallIntegerField(editable=False, verbose_name='shot number')),
                ('velocity_fps', models.DecimalField(decimal_places=1, max_digits=6, verbose_name='velocity (fps)')),
                ('notes', models.CharField(blank=True, max_length=255, verbose_name='notes')),
                ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shots', to='tools.shotgroup', verbose_name='group')),
            ],
            options={
                'verbose_name': 'shot',
                'verbose_name_plural': 'shots',
                'ordering': ['shot_number'],
            },
        ),
        migrations.AddConstraint(
            model_name='shot',
            constraint=models.UniqueConstraint(fields=('group', 'shot_number'), name='unique_shot_number_per_group'),
        ),
    ]
