From a5e50e1b328e7fe32c21a1bbd43c037c9f693cfa Mon Sep 17 00:00:00 2001 From: w940853815 Date: Fri, 14 Mar 2025 14:54:18 +0800 Subject: [PATCH] Revert "perf: migrations automationexecution type" This reverts commit f513eb62a695e539e3b9bde977af9c35e42d0be9. --- .../0015_automationexecution_type.py | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/apps/assets/migrations/0015_automationexecution_type.py b/apps/assets/migrations/0015_automationexecution_type.py index 348c291ce..c48dac755 100644 --- a/apps/assets/migrations/0015_automationexecution_type.py +++ b/apps/assets/migrations/0015_automationexecution_type.py @@ -1,27 +1,16 @@ # Generated by Django 4.1.13 on 2025-03-13 09:14 -import time + from django.db import migrations, models def migrate_execution_type(apps, schema_editor): - count = 0 - bulk_size = 1000 - while True: - start = time.time() - execution_model = apps.get_model('assets', 'AutomationExecution') - execution_objs = [] - executions = execution_model.objects.all()[count:count + bulk_size] - if not executions: - break - for execution in executions: - snapshot = execution.snapshot - execution.type = snapshot.get('type', '') - execution_objs.append(execution) - execution_model.objects.bulk_update(execution_objs, ['type']) - print("\tUpdate rexecutions: {}-{} using: {:.2f}s".format( - count, count + len(executions), time.time() - start - )) - count += len(executions) + execution_model = apps.get_model('assets', 'AutomationExecution') + execution_objs = [] + for execution in execution_model.objects.all(): + snapshot = execution.snapshot + execution.type = snapshot.get('type', '') + execution_objs.append(execution) + execution_model.objects.bulk_update(execution_objs, ['type']) class Migration(migrations.Migration):