fix(v2-import): namespace source identity for snapshot upserts
This commit is contained in:
@ -14,7 +14,8 @@ class Competition(models.Model):
|
||||
|
||||
name = models.CharField(max_length=220)
|
||||
slug = models.SlugField(max_length=240, unique=True)
|
||||
source_uid = models.CharField(max_length=120, blank=True, null=True, unique=True)
|
||||
source_name = models.CharField(max_length=120, blank=True, default="")
|
||||
source_uid = models.CharField(max_length=120, blank=True, null=True)
|
||||
competition_type = models.CharField(max_length=24, choices=CompetitionType.choices)
|
||||
gender = models.CharField(max_length=16, choices=Gender.choices, default=Gender.MEN)
|
||||
level = models.PositiveSmallIntegerField(default=1)
|
||||
@ -32,10 +33,16 @@ class Competition(models.Model):
|
||||
class Meta:
|
||||
ordering = ["name"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["name", "country"], name="uq_competition_name_country")
|
||||
models.UniqueConstraint(fields=["name", "country"], name="uq_competition_name_country"),
|
||||
models.UniqueConstraint(
|
||||
fields=["source_name", "source_uid"],
|
||||
condition=models.Q(source_uid__isnull=False) & ~models.Q(source_uid=""),
|
||||
name="uq_competition_source_namespace_uid",
|
||||
),
|
||||
]
|
||||
indexes = [
|
||||
models.Index(fields=["name"]),
|
||||
models.Index(fields=["source_name", "source_uid"]),
|
||||
models.Index(fields=["source_uid"]),
|
||||
models.Index(fields=["country"]),
|
||||
models.Index(fields=["competition_type"]),
|
||||
|
||||
Reference in New Issue
Block a user