Skip to content

Commit

Permalink
Merge pull request #1694 from st1020/feat/unique-name
Browse files Browse the repository at this point in the history
feat: add unique constraint to name field
  • Loading branch information
Bidaya0 authored Aug 3, 2023
2 parents 2e3a564 + 66da8a2 commit af164c5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
30 changes: 30 additions & 0 deletions dongtai_common/migrations/0006_auto_20230803_1407.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 3.2.20 on 2023-08-03 14:07

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("dongtai_common", "0005_iastprojectmetadata"),
]

operations = [
migrations.AlterField(
model_name="iastprojectgroup",
name="name",
field=models.CharField(max_length=255, unique=True),
),
migrations.AlterField(
model_name="iastrolev2",
name="name",
field=models.CharField(max_length=255, unique=True),
),
migrations.AddIndex(
model_name="iastprojectgroup",
index=models.Index(fields=["name"], name="iast_projec_name_336825_idx"),
),
migrations.AddIndex(
model_name="iastrolev2",
index=models.Index(fields=["name"], name="iast_role_name_711a1a_idx"),
),
]
3 changes: 2 additions & 1 deletion dongtai_common/models/iast_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RoleStatus(models.IntegerChoices):

class IastRoleV2(models.Model):
id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=255)
name = models.CharField(max_length=255, unique=True)
is_admin = models.BooleanField(default=False)
is_preset = models.BooleanField(default=False)
permission = models.JSONField()
Expand All @@ -19,3 +19,4 @@ class IastRoleV2(models.Model):
class Meta:
managed = get_managed()
db_table = "iast_role"
indexes = [models.Index(fields=["name"])]
3 changes: 2 additions & 1 deletion dongtai_common/models/project_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class IastProjectGroup(models.Model):
id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=255)
name = models.CharField(max_length=255, unique=True)
create_time = models.IntegerField(default=get_timestamp)
create_user = models.ForeignKey(User, models.DO_NOTHING, db_constraint=False, related_name="create_project_group")
users = models.ManyToManyField(User, through="IastProjectGroupUser")
Expand All @@ -17,6 +17,7 @@ class IastProjectGroup(models.Model):
class Meta:
managed = get_managed()
db_table = "iast_project_group"
indexes = [models.Index(fields=["name"])]


class IastProjectGroupProject(models.Model):
Expand Down

0 comments on commit af164c5

Please sign in to comment.