-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nazarii
committed
Feb 1, 2024
1 parent
0849a95
commit 3fba2bb
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Generated by Django 4.2.9 on 2024-02-01 21:30 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='SocialAccount', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('uid', models.CharField(blank=True, max_length=40, null=True, unique=True)), | ||
('provider', models.CharField(choices=[('google', 'Google')], max_length=20)), | ||
('connected', models.DateTimeField(auto_now_add=True)), | ||
( | ||
'user', | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='social_account', | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={ | ||
'indexes': [models.Index(fields=['provider', 'uid'], name='auth_app_so_provide_03d647_idx')], | ||
}, | ||
), | ||
migrations.AddConstraint( | ||
model_name='socialaccount', | ||
constraint=models.UniqueConstraint(fields=('user', 'provider'), name='unique_user_provider'), | ||
), | ||
migrations.AddConstraint( | ||
model_name='socialaccount', | ||
constraint=models.UniqueConstraint(fields=('provider', 'uid'), name='unique_uid_provider'), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.db import models | ||
|
||
|
||
class SocialAccountChoice(models.TextChoices): | ||
GOOGLE = 'google', | ||
|
||
|
||
class SocialAccount(models.Model): | ||
user = models.OneToOneField('main.User', on_delete=models.CASCADE, related_name='social_account') | ||
uid = models.CharField(max_length=40, blank=True, null=True, unique=True) | ||
provider = models.CharField(max_length=20, choices=SocialAccountChoice.choices) | ||
connected = models.DateTimeField(auto_now_add=True) | ||
|
||
class Meta: | ||
constraints = [ | ||
models.UniqueConstraint(fields=('user', 'provider'), name='unique_user_provider'), | ||
models.UniqueConstraint(fields=('provider', 'uid'), name='unique_uid_provider'), | ||
] | ||
indexes = [ | ||
models.Index(fields=('provider', 'uid')), | ||
] |