latest changes
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
# Generated by Django 6.1.2 on 2026-10-21 18:45
|
||||
|
||||
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', '0011_log_quantity'),
|
||||
('recipes', '0006_cooklater'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='GroceryItem',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('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=[('pieces', 'pieces'), ('g', 'g'), ('kg', 'kg'), ('ml', 'ml'), ('L', 'L'), ('packs', 'packs'), ('portions', 'portions'), ('tsp', 'tsp'), ('tbsp', 'tbsp')], max_length=10)),
|
||||
('category', models.CharField(blank=True, max_length=80)),
|
||||
('notes', models.TextField(blank=True)),
|
||||
('status', models.CharField(choices=[('needed', 'Needed'), ('purchased', 'Purchased')], default='needed', max_length=12)),
|
||||
('purchased_at', models.DateTimeField(blank=True, null=True)),
|
||||
('idempotency_key', models.CharField(blank=True, max_length=100)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='food.foodproduct')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='grocery_items', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'ordering': ('status', 'category', 'name', 'created_at'),
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='GrocerySource',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('requested_quantity', models.DecimalField(decimal_places=3, max_digits=10)),
|
||||
('requested_unit', models.CharField(max_length=10)),
|
||||
('selection_key', models.CharField(max_length=120)),
|
||||
('ingredient', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='recipes.recipeingredient')),
|
||||
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sources', to='groceries.groceryitem')),
|
||||
('recipe', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='recipes.recipe')),
|
||||
],
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='groceryitem',
|
||||
constraint=models.CheckConstraint(condition=models.Q(('quantity__gt', 0)), name='groceries_positive_quantity'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='groceryitem',
|
||||
constraint=models.UniqueConstraint(condition=models.Q(('idempotency_key', ''), _negated=True), fields=('user', 'idempotency_key'), name='groceries_unique_idempotency_key'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='grocerysource',
|
||||
constraint=models.UniqueConstraint(fields=('item', 'recipe', 'ingredient', 'selection_key'), name='groceries_unique_source'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,35 @@
|
||||
# Generated by Django 6.1.2 on 2026-10-21 18:46
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('food', '0011_log_quantity'),
|
||||
('groceries', '0001_initial'),
|
||||
('recipes', '0006_cooklater'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='GroceryRecipeDemand',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('selection_key', models.CharField(blank=True, max_length=120)),
|
||||
('name', models.CharField(max_length=180)),
|
||||
('quantity', models.DecimalField(decimal_places=3, max_digits=10)),
|
||||
('unit', models.CharField(max_length=10)),
|
||||
('ingredient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='recipes.recipeingredient')),
|
||||
('product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='food.foodproduct')),
|
||||
('recipe', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='recipes.recipe')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'constraints': [models.UniqueConstraint(fields=('user', 'recipe', 'ingredient', 'selection_key'), name='groceries_unique_recipe_demand')],
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,25 @@
|
||||
# Generated by Django 6.1.2 on 2026-10-21 18:49
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('food', '0011_log_quantity'),
|
||||
('groceries', '0002_groceryrecipedemand'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='groceryitem',
|
||||
name='inventory_transfer',
|
||||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='grocery_origin', to='food.kitcheninventoryitem'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='groceryitem',
|
||||
name='inventory_transferred_at',
|
||||
field=models.DateTimeField(blank=True, null=True),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user