diff --git a/src/bk-user/bkuser/apps/data_source/migrations/0003_auto_20231121_1201.py b/src/bk-user/bkuser/apps/data_source/migrations/0003_auto_20231121_1201.py new file mode 100644 index 000000000..cc876c8e9 --- /dev/null +++ b/src/bk-user/bkuser/apps/data_source/migrations/0003_auto_20231121_1201.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.20 on 2023-11-21 04:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('data_source', '0002_init_builtin_data_source_plugin'), + ] + + operations = [ + migrations.AlterField( + model_name='datasource', + name='name', + field=models.CharField(max_length=128, verbose_name='数据源名称'), + ), + migrations.AlterUniqueTogether( + name='datasource', + unique_together={('name', 'owner_tenant_id')}, + ), + ] diff --git a/src/bk-user/bkuser/apps/data_source/models.py b/src/bk-user/bkuser/apps/data_source/models.py index 926e9bde6..f331d1058 100644 --- a/src/bk-user/bkuser/apps/data_source/models.py +++ b/src/bk-user/bkuser/apps/data_source/models.py @@ -53,7 +53,7 @@ def create(self, *args, **kwargs): class DataSource(AuditedModel): - name = models.CharField("数据源名称", max_length=128, unique=True) + name = models.CharField("数据源名称", max_length=128) owner_tenant_id = models.CharField("归属租户", max_length=64, db_index=True) status = models.CharField( "数据源状态", @@ -73,6 +73,7 @@ class DataSource(AuditedModel): class Meta: ordering = ["id"] + unique_together = [("name", "owner_tenant_id")] @property def is_local(self) -> bool: