# Generated by Django 5.0 on 2026-03-01 15:46

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


class Migration(migrations.Migration):

    dependencies = [
        ('fertilizer', '0002_alter_fertilizationentry_fertilizer'),
        ('fields', '0006_e1c_chusankan_17_fields'),
    ]

    operations = [
        migrations.CreateModel(
            name='DistributionPlan',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200, verbose_name='計画名')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('fertilization_plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='distribution_plans', to='fertilizer.fertilizationplan', verbose_name='施肥計画')),
            ],
            options={
                'verbose_name': '分配計画',
                'verbose_name_plural': '分配計画',
                'ordering': ['-fertilization_plan__year', 'name'],
            },
        ),
        migrations.CreateModel(
            name='DistributionGroup',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, verbose_name='グループ名')),
                ('order', models.PositiveIntegerField(default=0, verbose_name='表示順')),
                ('distribution_plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='groups', to='fertilizer.distributionplan', verbose_name='分配計画')),
            ],
            options={
                'verbose_name': '分配グループ',
                'verbose_name_plural': '分配グループ',
                'ordering': ['order', 'id'],
                'unique_together': {('distribution_plan', 'name')},
            },
        ),
        migrations.CreateModel(
            name='DistributionGroupField',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('field', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='fields.field', verbose_name='圃場')),
                ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='field_assignments', to='fertilizer.distributiongroup', verbose_name='グループ')),
                ('distribution_plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fertilizer.distributionplan', verbose_name='分配計画')),
            ],
            options={
                'verbose_name': 'グループ圃場割り当て',
                'verbose_name_plural': 'グループ圃場割り当て',
                'ordering': ['field__display_order', 'field__id'],
                'unique_together': {('distribution_plan', 'field')},
            },
        ),
    ]
