Skip to content

Commit c8917f5

Browse files
committed
Changed the migration progress indication to a tqdm progress bar.
- Legacy-Id: 11862
1 parent a90af1e commit c8917f5

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

ietf/doc/migrations/0013_auto_20151027_1127.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import unicode_literals
33

44
import sys
5+
from tqdm import tqdm
56

67
from django.db import migrations
78

@@ -60,17 +61,14 @@ def get_model_fields_as_dict(obj):
6061
if objs.exists():
6162
try:
6263
dochist = objs.get(**fields)
63-
sys.stderr.write('.')
6464
except DocHistory.MultipleObjectsReturned:
6565
dochist_list = list(objs)
6666
for dochist in dochist_list[1:]:
6767
dochist.delete()
6868
dochist = dochist_list[0]
69-
sys.stderr.write('-')
7069
else:
7170
dochist = DocHistory(**fields)
7271
dochist.save()
73-
sys.stderr.write('+')
7472

7573
# copy many to many
7674
for field in doc._meta.many_to_many:
@@ -97,9 +95,13 @@ def transfer_fields(obj, HistModel):
9795
from django.conf import settings
9896
settings.DEBUG = False # prevent out-of-memory problems
9997

100-
for d in Document.objects.iterator():
98+
docs = Document.objects.all()
99+
for d in tqdm(docs):
101100
save_document_in_history(d)
102101

102+
def noop_backward(apps, schema_editor):
103+
pass
104+
103105
class Migration(migrations.Migration):
104106

105107
dependencies = [
@@ -108,6 +110,6 @@ class Migration(migrations.Migration):
108110
]
109111

110112
operations = [
111-
migrations.RunPython(fix_buggy_author_foreignkey),
112-
migrations.RunPython(save_all_documents_in_history)
113+
migrations.RunPython(fix_buggy_author_foreignkey, noop_backward),
114+
migrations.RunPython(save_all_documents_in_history, noop_backward)
113115
]

0 commit comments

Comments
 (0)