forked from mirrors/bookwyrm
Add unique constraint to followers relationship. #47
This commit is contained in:
parent
38ec3c554b
commit
e0266cb754
2 changed files with 22 additions and 0 deletions
17
fedireads/migrations/0007_auto_20200223_0902.py
Normal file
17
fedireads/migrations/0007_auto_20200223_0902.py
Normal 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'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -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 '''
|
||||||
|
|
Loading…
Reference in a new issue