From 6329d380b7ffcabd678ec1f9123b7a1d408269b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Tue, 28 Nov 2023 14:44:11 +0100 Subject: [PATCH] Editions are unique if name, platform OR year is different --- .../0033_alter_edition_unique_together.py | 17 +++++++++++++++++ games/models.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 games/migrations/0033_alter_edition_unique_together.py diff --git a/games/migrations/0033_alter_edition_unique_together.py b/games/migrations/0033_alter_edition_unique_together.py new file mode 100644 index 0000000..5565cba --- /dev/null +++ b/games/migrations/0033_alter_edition_unique_together.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.7 on 2023-11-28 13:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("games", "0032_alter_session_options_session_modified_at_and_more"), + ] + + operations = [ + migrations.AlterUniqueTogether( + name="edition", + unique_together={("name", "platform", "year_released")}, + ), + ] diff --git a/games/models.py b/games/models.py index 18d3c67..1b23611 100644 --- a/games/models.py +++ b/games/models.py @@ -34,7 +34,7 @@ class Game(models.Model): class Edition(models.Model): class Meta: - unique_together = [["name", "platform"]] + unique_together = [["name", "platform", "year_released"]] game = models.ForeignKey("Game", on_delete=models.CASCADE) name = models.CharField(max_length=255)