From f2520f63eaaace678ea92857260d1fede36e01fd Mon Sep 17 00:00:00 2001 From: crayon <873217631@qq.com> Date: Thu, 17 Aug 2023 16:49:38 +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 | 44 +++++++++++++++++++ pipeline/component_framework/models.py | 10 +++-- 2 files changed, 51 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..ca458b26d --- /dev/null +++ b/pipeline/component_framework/migrations/0007_auto_20230816_1537.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +""" +Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community +Edition) available. +Copyright (C) 2017-2019 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://opensource.org/licenses/MIT +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. +""" + + +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