# Generated by Django 5.0 on 2026-03-01 02:50

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('fields', '0006_e1c_chusankan_17_fields'),
        ('plans', '0004_crop_base_temp'),
    ]

    operations = [
        migrations.CreateModel(
            name='Fertilizer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, unique=True, verbose_name='肥料名')),
                ('maker', models.CharField(blank=True, max_length=100, null=True, verbose_name='メーカー')),
                ('capacity_kg', models.DecimalField(blank=True, decimal_places=3, max_digits=8, null=True, verbose_name='1袋重量(kg)')),
                ('nitrogen_pct', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True, verbose_name='窒素含有率(%)')),
                ('phosphorus_pct', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True, verbose_name='リン酸含有率(%)')),
                ('potassium_pct', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True, verbose_name='カリ含有率(%)')),
                ('notes', models.TextField(blank=True, null=True, verbose_name='備考')),
            ],
            options={
                'verbose_name': '肥料マスタ',
                'verbose_name_plural': '肥料マスタ',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='FertilizationPlan',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200, verbose_name='計画名')),
                ('year', models.IntegerField(verbose_name='年度')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('variety', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='fertilization_plans', to='plans.variety', verbose_name='品種')),
            ],
            options={
                'verbose_name': '施肥計画',
                'verbose_name_plural': '施肥計画',
                'ordering': ['-year', 'variety'],
            },
        ),
        migrations.CreateModel(
            name='FertilizationEntry',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('bags', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='袋数')),
                ('field', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fields.field', verbose_name='圃場')),
                ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='entries', to='fertilizer.fertilizationplan')),
                ('fertilizer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fertilizer.fertilizer', verbose_name='肥料')),
            ],
            options={
                'verbose_name': '施肥エントリ',
                'verbose_name_plural': '施肥エントリ',
                'ordering': ['field', 'fertilizer'],
                'unique_together': {('plan', 'field', 'fertilizer')},
            },
        ),
    ]
