migrations: Add progress output to confirmation backfill.

This makes it a lot easier to estimate how long this migration will
take to run. Additionally, document this migration in the upgrade notes.
This commit is contained in:
Tim Abbott 2021-09-17 11:16:10 -07:00
parent 7f9e5e2aad
commit ea6a40661c
2 changed files with 6 additions and 2 deletions

View File

@ -38,7 +38,8 @@ def set_expiry_date_for_existing_confirmations(
)
Confirmation.objects.bulk_update(confirmations, ["expiry_date"])
BATCH_SIZE = 1000
# Because the ranges in this code are inclusive, subtracting 1 offers round numbers.
BATCH_SIZE = 1000 - 1
first_id = Confirmation.objects.earliest("id").id
last_id = Confirmation.objects.latest("id").id
@ -46,6 +47,7 @@ def set_expiry_date_for_existing_confirmations(
id_range_lower_bound = first_id
id_range_upper_bound = first_id + BATCH_SIZE
while id_range_lower_bound <= last_id:
print(f"Processed {id_range_lower_bound} / {last_id}")
backfill_confirmations_between(id_range_lower_bound, id_range_upper_bound)
id_range_lower_bound = id_range_upper_bound + 1
id_range_upper_bound = id_range_lower_bound + BATCH_SIZE

View File

@ -31,7 +31,9 @@ log][commit-log] for an up-to-date list of raw changes.
#### Upgrade notes for 5.0
- None yet.
- This release contains a migration, `0009_confirmation_expiry_date_backfill`,
that can take several minutes to run on a server with millions of
messages of history.
#### Full feature changelog