perf: migrations type length

pull/15041/head
wangruidong 2025-03-14 15:07:18 +08:00 committed by w940853815
parent c80ca5236d
commit e4d169cabe
2 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,7 @@ from django.db import migrations, models
def migrate_execution_type(apps, schema_editor): def migrate_execution_type(apps, schema_editor):
count = 0 count = 0
bulk_size = 100 bulk_size = 1000
while True: while True:
start = time.time() start = time.time()
execution_model = apps.get_model('assets', 'AutomationExecution') execution_model = apps.get_model('assets', 'AutomationExecution')
@ -33,7 +33,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='automationexecution', model_name='automationexecution',
name='type', name='type',
field=models.CharField(default='', max_length=16, verbose_name='Type'), field=models.CharField(default='', max_length=32, verbose_name='Type'),
), ),
migrations.RunPython(migrate_execution_type) migrations.RunPython(migrate_execution_type)
] ]

View File

@ -142,7 +142,7 @@ class AutomationExecution(OrgModelMixin):
null=True, verbose_name=_("Date start"), db_index=True null=True, verbose_name=_("Date start"), db_index=True
) )
date_finished = models.DateTimeField(null=True, verbose_name=_("Date finished")) date_finished = models.DateTimeField(null=True, verbose_name=_("Date finished"))
type = models.CharField(default='', max_length=16, verbose_name=_("Type")) type = models.CharField(default='', max_length=32, verbose_name=_("Type"))
duration = models.DecimalField(default=0, max_digits=10, decimal_places=2, verbose_name=_("Duration")) duration = models.DecimalField(default=0, max_digits=10, decimal_places=2, verbose_name=_("Duration"))
snapshot = EncryptJsonDictTextField( snapshot = EncryptJsonDictTextField(
default=dict, blank=True, null=True, verbose_name=_("Automation snapshot") default=dict, blank=True, null=True, verbose_name=_("Automation snapshot")