correct migration V02.17.07
authorymh <ymh.work@gmail.com>
Wed, 16 Sep 2015 23:29:10 +0200
changeset 289 921467dd8ec8
parent 288 baf368e85fba
child 290 35af50f04d22
correct migration
src/ldtplatform/migrations/0002_correct_oauth_provider_migration.py
--- a/src/ldtplatform/migrations/0002_correct_oauth_provider_migration.py	Wed Sep 16 23:25:43 2015 +0200
+++ b/src/ldtplatform/migrations/0002_correct_oauth_provider_migration.py	Wed Sep 16 23:29:10 2015 +0200
@@ -6,8 +6,9 @@
 def update_oauth_provider_migration(apps, schema_editor):
     from django.db.migrations.recorder import MigrationRecorder
     count = MigrationRecorder.Migration.objects.filter(app='oauth_provider', name='0001_correct_oauth_provider_secret_size').count()
-    for r in MigrationRecorder.Migration.objects.filter(app='oauth_provider', name='0001_correct_oauth_provider_secret_size')[0:count-1]:
-        r.delete()
+    if count > 0:
+        for r in MigrationRecorder.Migration.objects.filter(app='oauth_provider', name='0001_correct_oauth_provider_secret_size')[0:count-1]:
+            r.delete()
     MigrationRecorder.Migration.objects.filter(app='oauth_provider', name='0001_correct_oauth_provider_secret_size').update(app='ldtplatform')
 
 def update_oauth_provider_migration_back(apps, schema_editor):