Self hosted FLOSS fitness/workout, nutrition and weight tracker
Consolidate migrations
Roland Geider69436eb98c0b
diff --git a/wger/trophies/migrations/0001_initial.py b/wger/trophies/migrations/0001_initial.pyindex 5f10ceca3..e183baea3 100644--- a/wger/trophies/migrations/0001_initial.py+++ b/wger/trophies/migrations/0001_initial.py@@ -220,6 +220,15 @@ class Migration(migrations.Migration):verbose_name='User',),),+ (+ 'last_complete_weekend_date',+ models.DateField(+ blank=True,+ help_text='Date of the last Saturday where both Sat and Sun had workouts',+ null=True,+ verbose_name='Last complete weekend date',+ )+ )],options={'verbose_name': 'User statistics',diff --git a/wger/trophies/migrations/0002_add_last_complete_weekend_date.py b/wger/trophies/migrations/0002_add_last_complete_weekend_date.pydeleted file mode 100644index 1efe35882..000000000--- a/wger/trophies/migrations/0002_add_last_complete_weekend_date.py+++ /dev/null@@ -1,22 +0,0 @@-# Generated by Django 5.2.8 on 2025-12-02 11:46--from django.db import migrations, models---class Migration(migrations.Migration):- dependencies = [- ('trophies', '0001_initial'),- ]-- operations = [- migrations.AddField(- model_name='userstatistics',- name='last_complete_weekend_date',- field=models.DateField(- blank=True,- help_text='Date of the last Saturday where both Sat and Sun had workouts',- null=True,- verbose_name='Last complete weekend date',- ),- ),- ]diff --git a/wger/trophies/migrations/0003_load_initial_trophies.py b/wger/trophies/migrations/0002_load_initial_trophies.pysimilarity index 91%rename from wger/trophies/migrations/0003_load_initial_trophies.pyrename to wger/trophies/migrations/0002_load_initial_trophies.pyindex 5b02d67fc..992c1efc8 100644--- a/wger/trophies/migrations/0003_load_initial_trophies.py+++ b/wger/trophies/migrations/0002_load_initial_trophies.py@@ -9,8 +9,8 @@ def load_initial_trophies(apps: StateApps, schema_editor: BaseDatabaseSchemaEdit"""Load the initial set of 9 trophies.- This migration is idempotent - it will skip trophies that already exist- based on the trophy name.+ This migration almost idempotent - it will update trophies that already exist+ based on the trophy UUID."""Trophy = apps.get_model('trophies', 'Trophy')@@ -117,18 +117,11 @@ def load_initial_trophies(apps: StateApps, schema_editor: BaseDatabaseSchemaEdit},]- created_count = 0- skipped_count = 0-for trophy_data in trophies_data:- # Check if trophy already exists- if not Trophy.objects.filter(name=trophy_data['name']).exists():- Trophy.objects.create(**trophy_data)- created_count += 1- else:- skipped_count += 1--+ Trophy.objects.update_or_create(+ name=trophy_data['uuid'],+ defaults=trophy_data+ )def reverse_load_trophies(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor):"""@@ -158,7 +151,7 @@ def reverse_load_trophies(apps: StateApps, schema_editor: BaseDatabaseSchemaEditclass Migration(migrations.Migration):dependencies = [- ('trophies', '0002_add_last_complete_weekend_date'),+ ('trophies', '0001_initial'),]operations = [diff --git a/wger/trophies/migrations/0004_trophy_is_repeatable_usertrophy_context_data.py b/wger/trophies/migrations/0004_add_pr_trophies.pysimilarity index 97%rename from wger/trophies/migrations/0004_trophy_is_repeatable_usertrophy_context_data.pyrename to wger/trophies/migrations/0004_add_pr_trophies.pyindex cab623678..2f0601f43 100644--- a/wger/trophies/migrations/0004_trophy_is_repeatable_usertrophy_context_data.py+++ b/wger/trophies/migrations/0004_add_pr_trophies.py@@ -30,7 +30,7 @@ def remove_personal_record_trophy(apps: StateApps, schema_editor: BaseDatabaseScclass Migration(migrations.Migration):dependencies = [- ('trophies', '0003_load_initial_trophies'),+ ('trophies', '0002_load_initial_trophies'),]operations = [