From e2394110d571b8e5e8f98d2b8a7530986a8987fd Mon Sep 17 00:00:00 2001 From: crayon <873217631@qq.com> Date: Wed, 16 Aug 2023 15:39:39 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E9=A1=B9=E7=9B=AE=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E5=8D=A1=E4=BD=8F=E7=9A=84=E9=97=AE=E9=A2=98=20(fixed=20#1743)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0007_auto_20230816_1537.py | 32 +++++++++++++++++++ pipeline/component_framework/models.py | 10 ++++-- 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 pipeline/component_framework/migrations/0007_auto_20230816_1537.py diff --git a/pipeline/component_framework/migrations/0007_auto_20230816_1537.py b/pipeline/component_framework/migrations/0007_auto_20230816_1537.py new file mode 100644 index 000000000..69338df6b --- /dev/null +++ b/pipeline/component_framework/migrations/0007_auto_20230816_1537.py @@ -0,0 +1,32 @@ +# Generated by Django 3.2.4 on 2023-08-16 07:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("component_framework", "0006_auto_20200213_0743"), + ] + + operations = [ + migrations.AlterField( + model_name="componentmodel", + name="code", + field=models.CharField(db_index=True, max_length=255, verbose_name="组件编码"), + ), + migrations.AlterField( + model_name="componentmodel", + name="name", + field=models.CharField(db_index=True, max_length=255, verbose_name="组件名称"), + ), + migrations.AlterField( + model_name="componentmodel", + name="version", + field=models.CharField(db_index=True, default="legacy", max_length=64, verbose_name="组件版本"), + ), + migrations.AddIndex( + model_name="componentmodel", + index=models.Index(fields=["code", "version"], name="idx_code_version"), + ), + ] diff --git a/pipeline/component_framework/models.py b/pipeline/component_framework/models.py index 8c6204009..0975e17d8 100644 --- a/pipeline/component_framework/models.py +++ b/pipeline/component_framework/models.py @@ -39,9 +39,9 @@ class ComponentModel(models.Model): 注册的组件 """ - code = models.CharField(_("组件编码"), max_length=255) - version = models.CharField(_("组件版本"), max_length=64, default=LEGACY_PLUGINS_VERSION) - name = models.CharField(_("组件名称"), max_length=255) + code = models.CharField(_("组件编码"), max_length=255, db_index=True) + version = models.CharField(_("组件版本"), max_length=64, default=LEGACY_PLUGINS_VERSION, db_index=True) + name = models.CharField(_("组件名称"), max_length=255, db_index=True) status = models.BooleanField(_("组件是否可用"), default=True) objects = ComponentManager() @@ -51,6 +51,10 @@ class Meta: verbose_name_plural = _("组件 Component") ordering = ["-id"] + indexes = [ + models.Index(fields=["code", "version"], name="idx_code_version"), + ] + def __unicode__(self): return self.name