# Generated by Django 6.1.1 on 2026-10-11 18:51 import django.core.validators import django.db.models.deletion import uuid from decimal import Decimal from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ('food', '0009_backfill_food_hydration'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Recipe', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('api_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)), ('title', models.CharField(max_length=180)), ('description', models.TextField(blank=True)), ('instructions_markdown', models.TextField(blank=True)), ('notes_markdown', models.TextField(blank=True)), ('photo', models.ImageField(blank=True, upload_to='recipes/%Y/%m/')), ('preparation_minutes', models.PositiveIntegerField(default=0)), ('cooking_minutes', models.PositiveIntegerField(default=0)), ('default_servings', models.DecimalField(decimal_places=2, default=2, max_digits=7, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))])), ('category', models.CharField(blank=True, max_length=80)), ('tags', models.JSONField(blank=True, default=list)), ('is_favourite', models.BooleanField(default=False)), ('status', models.CharField(choices=[('draft', 'Draft'), ('published', 'Published')], default='draft', max_length=12)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('copied_from', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='copies', to='recipes.recipe')), ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='recipes', to=settings.AUTH_USER_MODEL)), ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='variations', to='recipes.recipe')), ], options={ 'ordering': ('-updated_at', '-pk'), }, ), migrations.CreateModel( name='RecipeIngredient', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=180)), ('quantity', models.DecimalField(decimal_places=3, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.001'))])), ('unit', models.CharField(choices=[('g', 'g'), ('kg', 'kg'), ('ml', 'ml'), ('L', 'L'), ('pieces', 'pieces'), ('tsp', 'tsp'), ('tbsp', 'tbsp'), ('portions', 'portions')], max_length=10)), ('display_order', models.PositiveIntegerField(default=0)), ('preparation_note', models.CharField(blank=True, max_length=255)), ('is_optional', models.BooleanField(default=False)), ('inventory_product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='recipe_inventory_ingredients', to='food.foodproduct')), ('nutrition_product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='recipe_nutrition_ingredients', to='food.foodproduct')), ('recipe', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ingredients', to='recipes.recipe')), ], options={ 'ordering': ('display_order', 'pk'), }, ), migrations.CreateModel( name='RecipeIngredientSubstitution', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=180)), ('quantity', models.DecimalField(decimal_places=3, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.001'))])), ('unit', models.CharField(choices=[('g', 'g'), ('kg', 'kg'), ('ml', 'ml'), ('L', 'L'), ('pieces', 'pieces'), ('tsp', 'tsp'), ('tbsp', 'tbsp'), ('portions', 'portions')], max_length=10)), ('display_order', models.PositiveIntegerField(default=0)), ('ingredient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='substitutions', to='recipes.recipeingredient')), ('product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='recipe_substitutions', to='food.foodproduct')), ], options={ 'ordering': ('display_order', 'pk'), }, ), migrations.CreateModel( name='RecipeSubrecipe', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('quantity', models.DecimalField(decimal_places=3, default=1, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.001'))])), ('unit', models.CharField(choices=[('servings', 'servings'), ('g', 'g'), ('ml', 'ml')], default='servings', max_length=16)), ('display_order', models.PositiveIntegerField(default=0)), ('note', models.CharField(blank=True, max_length=255)), ('component', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='used_in_recipes', to='recipes.recipe')), ('recipe', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subrecipes', to='recipes.recipe')), ], options={ 'ordering': ('display_order', 'pk'), }, ), migrations.AddConstraint( model_name='recipe', constraint=models.CheckConstraint(condition=models.Q(('default_servings__gt', 0)), name='recipes_positive_servings'), ), migrations.AddConstraint( model_name='recipeingredient', constraint=models.CheckConstraint(condition=models.Q(('quantity__gt', 0)), name='recipes_positive_ingredient_quantity'), ), migrations.AddConstraint( model_name='recipesubrecipe', constraint=models.UniqueConstraint(fields=('recipe', 'component'), name='recipes_unique_component'), ), ]