Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Fix the migrations when running on a postgreSQL server

Roland Geider7ef373924157
diff --git a/wger/exercises/migrations/0002_auto__add_field_exercise_user__add_field_exercise_status.py b/wger/exercises/migrations/0002_auto__add_field_exercise_user__add_field_exercise_status.py
index 5821304e8..26392d0cc 100644
--- a/wger/exercises/migrations/0002_auto__add_field_exercise_user__add_field_exercise_status.py
+++ b/wger/exercises/migrations/0002_auto__add_field_exercise_user__add_field_exercise_status.py
@@ -18,10 +18,14 @@ class Migration(SchemaMigration):
db.add_column('exercises_exercise', 'status',
self.gf('django.db.models.fields.CharField')(default='1', max_length=2),
keep_default=False)
+
# Set the status 'system' for all existing exercises in the database
+ db.start_transaction()
if not db.dry_run:
orm.Exercise.objects.all().update(status=Exercise.EXERCISE_STATUS_SYSTEM)
-
+ db.commit_transaction()
+ # Note: we need to open and close the transaction here for postgresql.
+ # see https://github.com/rolandgeider/wger/issues/26
# Adding field 'Exercise.creation_date'
db.add_column('exercises_exercise', 'creation_date',
diff --git a/wger/nutrition/migrations/0007_auto__add_field_ingredient_user__add_field_ingredient_status.py b/wger/nutrition/migrations/0007_auto__add_field_ingredient_user__add_field_ingredient_status.py
index c64d4d974..2c203b0d8 100644
--- a/wger/nutrition/migrations/0007_auto__add_field_ingredient_user__add_field_ingredient_status.py
+++ b/wger/nutrition/migrations/0007_auto__add_field_ingredient_user__add_field_ingredient_status.py
@@ -20,8 +20,12 @@ class Migration(SchemaMigration):
keep_default=False)
# Set the status 'system' for all existing ingredients in the database
+ db.start_transaction()
if not db.dry_run:
orm.Ingredient.objects.all().update(status=Ingredient.INGREDIENT_STATUS_SYSTEM)
+ db.commit_transaction()
+ # Note: we need to open and close the transaction here for postgresql.
+ # see https://github.com/rolandgeider/wger/issues/26
def backwards(self, orm):