Skip to content

Commit 54befcb

Browse files
authored
Merge pull request #4451 from kobotoolbox/fix-migration-0050-warning
Display long-run warning for migration 0050 only where appropriate
2 parents 7646a69 + 9d9ec11 commit 54befcb

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

kpi/migrations/0050_add_indexes_to_import_and_export_tasks.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ def manually_drop_indexes_instructions(apps, schema_editor):
4747
"""
4848
)
4949

50+
def warning_long_run(apps, schema_editor):
51+
print(
52+
"""
53+
This might take a while. If it is too slow, you may want to
54+
interrupt this migration, cancel any outstanding `CREATE…` or `DROP
55+
INDEX` queries on `kpi_importtask` and `kpi_exporttask`, re-run the
56+
migration with `SKIP_HEAVY_MIGRATIONS=True`, and then follow the
57+
printed instructions to set up the indexes concurrently (without
58+
downtime) using raw SQL.
59+
"""
60+
)
61+
5062

5163
class Migration(migrations.Migration):
5264

@@ -55,17 +67,8 @@ class Migration(migrations.Migration):
5567
]
5668

5769
if not settings.SKIP_HEAVY_MIGRATIONS:
58-
print(
59-
"""
60-
This might take a while. If it is too slow, you may want to
61-
interrupt this migration, cancel any outstanding `CREATE…` or `DROP
62-
INDEX` queries on `kpi_importtask` and `kpi_exporttask`, re-run the
63-
migration with `SKIP_HEAVY_MIGRATIONS=True`, and then follow the
64-
printed instructions to set up the indexes concurrently (without
65-
downtime) using raw SQL.
66-
"""
67-
)
6870
operations = [
71+
migrations.RunPython(warning_long_run, warning_long_run),
6972
migrations.AddIndex(
7073
model_name='importtask',
7174
index=django.contrib.postgres.indexes.BTreeIndex(

0 commit comments

Comments
 (0)