diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index def1de413..baefce6bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v4 - uses: awalsh128/cache-apt-pkgs-action@v1.4.3 with: - packages: libsasl2-dev python3-dev libldap2-dev libssl-dev + packages: libsasl2-dev python3-dev libxml2-dev libxslt-dev libldap2-dev libssl-dev gcc musl-dev postgresql-dev zlib-dev jpeg-dev libwebp-dev openssl-dev libffi-dev cargo openldap-dev python3-dev xmlsec-dev xmlsec build-base g++ curl version: 1.0 # Setup python & dependencies diff --git a/cookbook/migrations/0220_shoppinglistrecipe_created_by_and_more.py b/cookbook/migrations/0220_shoppinglistrecipe_created_by_and_more.py index c8dac6ed9..4ebbbc1f9 100644 --- a/cookbook/migrations/0220_shoppinglistrecipe_created_by_and_more.py +++ b/cookbook/migrations/0220_shoppinglistrecipe_created_by_and_more.py @@ -3,34 +3,6 @@ from django.conf import settings from django.db import migrations, models import django.db.models.deletion -from django.db.models import F, Count -from django_scopes import scopes_disabled - - -def add_space_and_owner_to_shopping_list_recipe(apps, schema_editor): - print('migrating shopping list recipe space attribute, this might take a while ...') - with scopes_disabled(): - ShoppingListRecipe = apps.get_model('cookbook', 'ShoppingListRecipe') - - # delete all shopping list recipes that do not have entries as those are of no use anyway - ShoppingListRecipe.objects.annotate(entry_count=Count('entries')).filter(entry_count__lte=0).delete() - - shopping_list_recipes = ShoppingListRecipe.objects.all().prefetch_related('entries') - update_list = [] - - for slr in shopping_list_recipes: - if entry := slr.entries.first(): - if entry.space and entry.created_by: - slr.space = entry.space - slr.created_by = entry.created_by - update_list.append(slr) - else: - print(slr, 'missing data on entry') - else: - print(slr, 'missing entry') - - ShoppingListRecipe.objects.bulk_update(update_list, ['space', 'created_by'], batch_size=500) - class Migration(migrations.Migration): dependencies = [ @@ -49,5 +21,4 @@ class Migration(migrations.Migration): name='space', field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='cookbook.space'), ), - migrations.RunPython(add_space_and_owner_to_shopping_list_recipe), ] diff --git a/cookbook/migrations/0221_migrate_shoppinglistrecipe_space_created_by.py b/cookbook/migrations/0221_migrate_shoppinglistrecipe_space_created_by.py new file mode 100644 index 000000000..22323696c --- /dev/null +++ b/cookbook/migrations/0221_migrate_shoppinglistrecipe_space_created_by.py @@ -0,0 +1,42 @@ +# Generated by Django 4.2.18 on 2025-03-14 10:50 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +from django.db.models import F, Count +from django_scopes import scopes_disabled + + +def add_space_and_owner_to_shopping_list_recipe(apps, schema_editor): + print('migrating shopping list recipe space attribute, this might take a while ...') + with scopes_disabled(): + ShoppingListRecipe = apps.get_model('cookbook', 'ShoppingListRecipe') + + # delete all shopping list recipes that do not have entries as those are of no use anyway + ShoppingListRecipe.objects.annotate(entry_count=Count('entries')).filter(entry_count__lte=0).delete() + + shopping_list_recipes = ShoppingListRecipe.objects.all().prefetch_related('entries') + update_list = [] + + for slr in shopping_list_recipes: + if entry := slr.entries.first(): + if entry.space and entry.created_by: + slr.space = entry.space + slr.created_by = entry.created_by + update_list.append(slr) + else: + print(slr, 'missing data on entry') + else: + print(slr, 'missing entry') + + ShoppingListRecipe.objects.bulk_update(update_list, ['space', 'created_by'], batch_size=500) + + +class Migration(migrations.Migration): + dependencies = [ + ('cookbook', '0220_shoppinglistrecipe_created_by_and_more'), + ] + + operations = [ + migrations.RunPython(add_space_and_owner_to_shopping_list_recipe), + ] diff --git a/cookbook/migrations/0221_alter_shoppinglistrecipe_created_by_and_more.py b/cookbook/migrations/0222_alter_shoppinglistrecipe_created_by_and_more.py similarity index 91% rename from cookbook/migrations/0221_alter_shoppinglistrecipe_created_by_and_more.py rename to cookbook/migrations/0222_alter_shoppinglistrecipe_created_by_and_more.py index a27f7ad34..199f893f5 100644 --- a/cookbook/migrations/0221_alter_shoppinglistrecipe_created_by_and_more.py +++ b/cookbook/migrations/0222_alter_shoppinglistrecipe_created_by_and_more.py @@ -9,7 +9,7 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('cookbook', '0220_shoppinglistrecipe_created_by_and_more'), + ('cookbook', '0221_migrate_shoppinglistrecipe_space_created_by'), ] operations = [