From 9d9ec11efb1061ba946ed87862e9424786648b77 Mon Sep 17 00:00:00 2001 From: "John N. Milner" Date: Wed, 24 May 2023 19:20:59 -0400 Subject: [PATCH] =?UTF-8?q?Display=20long-run=20warning=20for=20migration?= =?UTF-8?q?=200050=20only=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit where appropriate --- ..._add_indexes_to_import_and_export_tasks.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/kpi/migrations/0050_add_indexes_to_import_and_export_tasks.py b/kpi/migrations/0050_add_indexes_to_import_and_export_tasks.py index a5b65bf0e7..decc6bb8df 100644 --- a/kpi/migrations/0050_add_indexes_to_import_and_export_tasks.py +++ b/kpi/migrations/0050_add_indexes_to_import_and_export_tasks.py @@ -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): @@ -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(