Add unique constraint to followers relationship. #47

This commit is contained in:
Adam Kelly 2020-02-23 09:08:11 +00:00
parent 38ec3c554b
commit e0266cb754
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,17 @@
# Generated by Django 3.0.3 on 2020-02-23 09:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('fedireads', '0006_auto_20200221_1702'),
]
operations = [
migrations.AddConstraint(
model_name='userrelationship',
constraint=models.UniqueConstraint(fields=('user_subject', 'user_object'), name='followers_unique'),
),
]

View file

@ -73,6 +73,11 @@ class UserRelationship(FedireadsModel):
status = models.CharField(max_length=100, default='follows', null=True) status = models.CharField(max_length=100, default='follows', null=True)
relationship_id = models.CharField(max_length=100) relationship_id = models.CharField(max_length=100)
class Meta:
constraints = [
models.UniqueConstraint(fields=['user_subject', 'user_object'], name='followers_unique')
]
@property @property
def absolute_id(self): def absolute_id(self):
''' use shelf identifier as absolute id ''' ''' use shelf identifier as absolute id '''