Skip to content

Commit

Permalink
Ajoute une contrainte d'unicité sur PrivateTopicRead
Browse files Browse the repository at this point in the history
  • Loading branch information
philippemilink committed Dec 10, 2023
1 parent fbdd980 commit 6f288e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions zds/mp/migrations/0008_unique_privatetopicread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.2.21 on 2023-11-24 22:16

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("mp", "0007_add_votes_to_private_post"),
]

operations = [
migrations.AddConstraint(
model_name="privatetopicread",
constraint=models.UniqueConstraint(fields=("privatetopic", "user"), name="unique_privatetopicread"),
),
]
1 change: 1 addition & 0 deletions zds/mp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ class PrivateTopicRead(models.Model):
class Meta:
verbose_name = "Message privé lu"
verbose_name_plural = "Messages privés lus"
constraints = [models.UniqueConstraint(fields=["privatetopic", "user"], name="unique_privatetopicread")]

privatetopic = models.ForeignKey(PrivateTopic, db_index=True, on_delete=models.CASCADE)
privatepost = models.ForeignKey(PrivatePost, db_index=True, on_delete=models.CASCADE)
Expand Down

0 comments on commit 6f288e9

Please sign in to comment.