@@ -0,0 +1,1146 @@
+# Generated by Django 2.2.8 on 2019-12-09 21:03%0A%0Afrom django.db import migrations%0A%0ABATCH_SIZE = 2500%0A%0A%0Adef populate_is_squashed(apps, schema_editor):%0A    DailyCount = apps.get_model(%22statistics%22, %22DailyCount%22)%0A    DailySecondTotalCount = apps.get_model(%22statistics%22, %22DailySecondTotalCount%22)%0A    TotalCount = apps.get_model(%22statistics%22, %22TotalCount%22)%0A%0A    populate_for_model(DailyCount)%0A    populate_for_model(DailySecondTotalCount)%0A    populate_for_model(TotalCount)%0A%0A%0Adef populate_for_model(model):%0A    max_id = 0%0A    num_updated = 0%0A    while True:%0A        id_batch = list(model.objects.filter(id__gt=max_id, is_squashed=None).values_list(%22id%22, flat=True).order_by(%22id%22)%5B:BATCH_SIZE%5D)%0A        if not id_batch:%0A            break%0A%0A        model.objects.filter(id__in=id_batch).update(is_squashed=True)%0A        max_id = id_batch%5B-1%5D%0A        num_updated += len(id_batch)%0A        %0A        print(f%22 %3E Updated %7Bnum_updated%7D instances of %7Bmodel.name%7D%22)%0A%0A%0Aclass Migration(migrations.Migration):%0A%0A    dependencies = %5B%0A        ('statistics', '0014_auto_20191209_1933'),%0A    %5D%0A%0A    operations = %5B%0A        migrations.RunPython(populate_is_squashed)%0A    %5D%0A

Add migration to backfill is_squashed on squashable models