Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display long-run warning for migration 0050 only where appropriate #4451

Merged
merged 1 commit into from
May 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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