Skip to content

Commit e3934a8

Browse files
authored
Merge pull request #5 from anish5256/master
Remove Unique Constrain for device_id and Added User and device_id unique together
2 parents d527820 + 98cb82b commit e3934a8

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by Django 3.2.18 on 2024-10-17 07:16
2+
3+
from django.conf import settings
4+
from django.db import migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
11+
('authtoken', '0004_auto_20240927_1224'),
12+
]
13+
14+
operations = [
15+
migrations.RemoveConstraint(
16+
model_name='token',
17+
name='unique_device_id_not_null_blank',
18+
),
19+
migrations.AlterUniqueTogether(
20+
name='token',
21+
unique_together={('user', 'device_id')},
22+
),
23+
]
24+

drfpasswordless/authtoken/models.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,7 @@ class Meta:
4242
abstract = 'drfpasswordless.authtoken' not in settings.INSTALLED_APPS
4343
verbose_name = _("Token")
4444
verbose_name_plural = _("Tokens")
45-
unique_together = (('key', 'device_id'),)
46-
constraints = [
47-
models.UniqueConstraint(
48-
fields=['device_id'],
49-
name='unique_device_id_not_null_blank',
50-
condition=Q(device_id__isnull=False) & ~Q(device_id='')
51-
)
52-
]
45+
unique_together = (('user', 'device_id'),)
5346

5447
def save(self, *args, **kwargs):
5548
if not self.key:

0 commit comments

Comments
 (0)