Skip to content

Commit

Permalink
Add unique constraint for AccountLog
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Oct 12, 2023
1 parent fc34ead commit 2585bfb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.5 on 2023-10-12 18:06

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("frontend", "0007_accountlog_specialprofileusedrecord_and_more"),
]

operations = [
migrations.AddConstraint(
model_name="accountlog",
constraint=models.UniqueConstraint(
fields=("account", "content_type"),
name="unique_account_log_for_each_type",
),
),
]
6 changes: 6 additions & 0 deletions frontend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class AccountLog(models.Model):

def __str__(self):
return f"Account {self.account.pk} ({self.content_type} {self.contents})"

class Meta:
constraints = [
models.UniqueConstraint(fields=['account', 'content_type'],
name='unique_account_log_for_each_type'),
]


# 记录需要在首次登录后显示换组页面并且已经换组的用户
Expand Down

0 comments on commit 2585bfb

Please sign in to comment.