Skip to content

Commit

Permalink
Merge pull request #4451 from kobotoolbox/fix-migration-0050-warning
Browse files Browse the repository at this point in the history
Display long-run warning for migration 0050 only where appropriate
  • Loading branch information
noliveleger authored May 24, 2023
2 parents 7646a69 + 9d9ec11 commit 54befcb
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions kpi/migrations/0050_add_indexes_to_import_and_export_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ def manually_drop_indexes_instructions(apps, schema_editor):
"""
)

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


class Migration(migrations.Migration):

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

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

0 comments on commit 54befcb

Please sign in to comment.