Skip to content

Commit

Permalink
feat(venue): make sure we unique based on name, city, and state (when…
Browse files Browse the repository at this point in the history
… present)

note that if state is NULL (or blank), you can still have duplicate venues as databases treat NULL values as distinct
  • Loading branch information
soehlert committed Oct 20, 2023
1 parent 95b8508 commit 70cba6c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion concerts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Venue(models.Model):
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
unique_together = ["name", "city"]
constraints = [models.UniqueConstraint(fields=["name", "city", "state"], name="unique_venue")]

def __str__(self):
if self.country:
Expand Down

0 comments on commit 70cba6c

Please sign in to comment.