Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Cleanup

Roland Geiderce35914825b0
diff --git a/wger/nutrition/migrations/0037_powersync_synced_ingredient_tables.py b/wger/nutrition/migrations/0037_powersync_synced_ingredient_tables.py
index d50620089..9d264fa9a 100644
--- a/wger/nutrition/migrations/0037_powersync_synced_ingredient_tables.py
+++ b/wger/nutrition/migrations/0037_powersync_synced_ingredient_tables.py
@@ -22,6 +22,9 @@ Other tables such as ``nutrition_image`` and ``nutrition_ingredientweightunit``
are synced directly, since at least currently it doesn't seem necessary to add
any shadow tables of their own.
+Note that currently the shadow table will grow monotonically, as no ingredients
+are ever removed from there. Should this ever become a problem in the future,
+new triggers will need to be added.
Keeping the shadow table in lockstep when the ingredient schema changes
-----------------------------------------------------------------------
diff --git a/wger/trophies/migrations/0003_migrate_context_data_uuids.py b/wger/trophies/migrations/0003_migrate_context_data_uuids.py
index dffd5861f..e47bbd437 100644
--- a/wger/trophies/migrations/0003_migrate_context_data_uuids.py
+++ b/wger/trophies/migrations/0003_migrate_context_data_uuids.py
@@ -30,16 +30,16 @@ def migrate_context_data_uuids(apps: StateApps, schema_editor):
log_id = context.get('log_id')
if isinstance(log_id, int):
uuid = resolve(log_uuid_cache, WorkoutLog, log_id)
- if uuid is not None:
- context['log_id'] = str(uuid)
- changed = True
+ # Replace the int PK with the UUID string, or clear a dangling
+ # reference to a log that no longer exists
+ context['log_id'] = str(uuid) if uuid is not None else None
+ changed = True
session_id = context.get('session_id')
if isinstance(session_id, int):
uuid = resolve(session_uuid_cache, WorkoutSession, session_id)
- if uuid is not None:
- context['session_id'] = str(uuid)
- changed = True
+ context['session_id'] = str(uuid) if uuid is not None else None
+ changed = True
if changed:
user_trophy.context_data = context