mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
28 lines
689 B
Python
28 lines
689 B
Python
# Generated by Django 3.1.4 on 2020-12-26 14:51
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
def migrate_empty_units(apps, schema_editor):
|
|
Unit = apps.get_model('cookbook', 'Unit')
|
|
Step = apps.get_model('cookbook', 'Step')
|
|
|
|
empty_units = Unit.objects.filter(name='').all()
|
|
for x in empty_units:
|
|
for s in Step.objects.all():
|
|
for i in s.ingredients.all():
|
|
if i.unit == x:
|
|
i.unit = None
|
|
i.save()
|
|
x.delete()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
('cookbook', '0090_auto_20201214_1359'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(migrate_empty_units),
|
|
]
|