From f3cc8d5422b6a8234e7cf72c2fc6fa731d868739 Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 12 Sep 2023 11:50:30 -0700 Subject: [PATCH] 13745 update migrations to use batch_size --- .../dcim/migrations/0177_devicetype_component_counters.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netbox/dcim/migrations/0177_devicetype_component_counters.py b/netbox/dcim/migrations/0177_devicetype_component_counters.py index 66d1460d9..a8e37e5ee 100644 --- a/netbox/dcim/migrations/0177_devicetype_component_counters.py +++ b/netbox/dcim/migrations/0177_devicetype_component_counters.py @@ -6,7 +6,7 @@ import utilities.fields def recalculate_devicetype_template_counts(apps, schema_editor): DeviceType = apps.get_model("dcim", "DeviceType") - device_types = list(DeviceType.objects.all().annotate( + device_types = DeviceType.objects.all().annotate( _console_port_template_count=Count('consoleporttemplates', distinct=True), _console_server_port_template_count=Count('consoleserverporttemplates', distinct=True), _power_port_template_count=Count('powerporttemplates', distinct=True), @@ -17,7 +17,7 @@ def recalculate_devicetype_template_counts(apps, schema_editor): _device_bay_template_count=Count('devicebaytemplates', distinct=True), _module_bay_template_count=Count('modulebaytemplates', distinct=True), _inventory_item_template_count=Count('inventoryitemtemplates', distinct=True), - )) + ) for devicetype in device_types: devicetype.console_port_template_count = devicetype._console_port_template_count @@ -42,7 +42,7 @@ def recalculate_devicetype_template_counts(apps, schema_editor): 'device_bay_template_count', 'module_bay_template_count', 'inventory_item_template_count', - ]) + ], batch_size=100) class Migration(migrations.Migration):