mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-23 18:29:23 -05:00
fixed FDC migration
This commit is contained in:
@@ -4,11 +4,6 @@ from django.db import migrations, models
|
||||
from django_scopes import scopes_disabled
|
||||
|
||||
|
||||
def fix_fdc_ids(apps, schema_editor):
|
||||
with scopes_disabled():
|
||||
# in case any food had a non digit fdc ID before this migration, remove it
|
||||
Food = apps.get_model('cookbook', 'Food')
|
||||
Food.objects.exclude(fdc_id__regex=r'^\d+$').exclude(fdc_id=None).update(fdc_id=None)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@@ -17,7 +12,6 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(fix_fdc_ids),
|
||||
migrations.AddField(
|
||||
model_name='propertytype',
|
||||
name='fdc_id',
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
# Generated by Django 4.2.7 on 2023-11-29 19:44
|
||||
|
||||
from django.db import migrations, models
|
||||
from django_scopes import scopes_disabled
|
||||
|
||||
|
||||
def fix_fdc_ids(apps, schema_editor):
|
||||
with scopes_disabled():
|
||||
# in case any food had a non digit fdc ID before this migration, remove it
|
||||
Food = apps.get_model('cookbook', 'Food')
|
||||
Food.objects.exclude(fdc_id__regex=r'^\d+$').exclude(fdc_id=None).update(fdc_id=None)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cookbook', '0204_propertytype_fdc_id'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(fix_fdc_ids),
|
||||
migrations.AlterField(
|
||||
model_name='food',
|
||||
name='fdc_id',
|
||||
|
||||
Reference in New Issue
Block a user