11from django .conf import settings
2+ import django .db .models .deletion
23from django .db import migrations , models
34
45import oauth2_provider .generators
78
89
910class Migration (migrations .Migration ):
10-
11+ """
12+ The following migrations are squashed here:
13+ - 0001_initial.py
14+ - 0002_08_updates.py
15+ - 0003_auto_20160316_1503.py
16+ - 0004_auto_20160525_1623.py
17+ - 0005_auto_20170514_1141.py
18+ - 0006_auto_20171214_2232.py
19+ """
1120 dependencies = [
1221 migrations .swappable_dependency (settings .AUTH_USER_MODEL )
1322 ]
@@ -16,14 +25,17 @@ class Migration(migrations.Migration):
1625 migrations .CreateModel (
1726 name = 'Application' ,
1827 fields = [
19- ('id' , models .AutoField ( verbose_name = 'ID' , serialize = False , auto_created = True , primary_key = True )),
28+ ('id' , models .BigAutoField ( serialize = False , primary_key = True )),
2029 ('client_id' , models .CharField (default = oauth2_provider .generators .generate_client_id , unique = True , max_length = 100 , db_index = True )),
2130 ('redirect_uris' , models .TextField (help_text = 'Allowed URIs list, space separated' , blank = True )),
2231 ('client_type' , models .CharField (max_length = 32 , choices = [('confidential' , 'Confidential' ), ('public' , 'Public' )])),
2332 ('authorization_grant_type' , models .CharField (max_length = 32 , choices = [('authorization-code' , 'Authorization code' ), ('implicit' , 'Implicit' ), ('password' , 'Resource owner password-based' ), ('client-credentials' , 'Client credentials' )])),
2433 ('client_secret' , models .CharField (default = oauth2_provider .generators .generate_client_secret , max_length = 255 , db_index = True , blank = True )),
2534 ('name' , models .CharField (max_length = 255 , blank = True )),
26- ('user' , models .ForeignKey (to = settings .AUTH_USER_MODEL , on_delete = models .CASCADE )),
35+ ('user' , models .ForeignKey (related_name = "oauth2_provider_application" , blank = True , to = settings .AUTH_USER_MODEL , null = True , on_delete = models .CASCADE )),
36+ ('skip_authorization' , models .BooleanField (default = False )),
37+ ('created' , models .DateTimeField (auto_now_add = True )),
38+ ('updated' , models .DateTimeField (auto_now = True )),
2739 ],
2840 options = {
2941 'abstract' : False ,
@@ -33,12 +45,16 @@ class Migration(migrations.Migration):
3345 migrations .CreateModel (
3446 name = 'AccessToken' ,
3547 fields = [
36- ('id' , models .AutoField ( verbose_name = 'ID' , serialize = False , auto_created = True , primary_key = True )),
37- ('token' , models .CharField (max_length = 255 , db_index = True )),
48+ ('id' , models .BigAutoField ( serialize = False , primary_key = True )),
49+ ('token' , models .CharField (unique = True , max_length = 255 )),
3850 ('expires' , models .DateTimeField ()),
3951 ('scope' , models .TextField (blank = True )),
40- ('application' , models .ForeignKey (to = oauth2_settings .APPLICATION_MODEL , on_delete = models .CASCADE )),
41- ('user' , models .ForeignKey (to = settings .AUTH_USER_MODEL , on_delete = models .CASCADE )),
52+ ('application' , models .ForeignKey (blank = True , null = True , on_delete = django .db .models .deletion .CASCADE , to = oauth2_settings .APPLICATION_MODEL )),
53+ ('user' , models .ForeignKey (blank = True , null = True , on_delete = django .db .models .deletion .CASCADE , related_name = 'oauth2_provider_accesstoken' , to = settings .AUTH_USER_MODEL )),
54+ ('created' , models .DateTimeField (auto_now_add = True )),
55+ ('updated' , models .DateTimeField (auto_now = True )),
56+ # Circular reference. Can't add it here.
57+ #('source_refresh_token', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=oauth2_settings.REFRESH_TOKEN_MODEL, related_name="refreshed_access_token")),
4258 ],
4359 options = {
4460 'abstract' : False ,
@@ -48,13 +64,15 @@ class Migration(migrations.Migration):
4864 migrations .CreateModel (
4965 name = 'Grant' ,
5066 fields = [
51- ('id' , models .AutoField ( verbose_name = 'ID' , serialize = False , auto_created = True , primary_key = True )),
52- ('code' , models .CharField (max_length = 255 , db_index = True )),
67+ ('id' , models .BigAutoField ( serialize = False , primary_key = True )),
68+ ('code' , models .CharField (unique = True , max_length = 255 )),
5369 ('expires' , models .DateTimeField ()),
5470 ('redirect_uri' , models .CharField (max_length = 255 )),
5571 ('scope' , models .TextField (blank = True )),
5672 ('application' , models .ForeignKey (to = oauth2_settings .APPLICATION_MODEL , on_delete = models .CASCADE )),
57- ('user' , models .ForeignKey (to = settings .AUTH_USER_MODEL , on_delete = models .CASCADE )),
73+ ('user' , models .ForeignKey (on_delete = django .db .models .deletion .CASCADE , related_name = 'oauth2_provider_grant' , to = settings .AUTH_USER_MODEL )),
74+ ('created' , models .DateTimeField (auto_now_add = True )),
75+ ('updated' , models .DateTimeField (auto_now = True )),
5876 ],
5977 options = {
6078 'abstract' : False ,
@@ -64,15 +82,24 @@ class Migration(migrations.Migration):
6482 migrations .CreateModel (
6583 name = 'RefreshToken' ,
6684 fields = [
67- ('id' , models .AutoField ( verbose_name = 'ID' , serialize = False , auto_created = True , primary_key = True )),
68- ('token' , models .CharField (max_length = 255 , db_index = True )),
69- ('access_token' , models .OneToOneField (related_name = ' refresh_token' , to = oauth2_settings .ACCESS_TOKEN_MODEL , on_delete = models .CASCADE )),
85+ ('id' , models .BigAutoField ( serialize = False , primary_key = True )),
86+ ('token' , models .CharField (max_length = 255 )),
87+ ('access_token' , models .OneToOneField (blank = True , null = True , related_name = " refresh_token" , to = oauth2_settings .ACCESS_TOKEN_MODEL , on_delete = models .SET_NULL )),
7088 ('application' , models .ForeignKey (to = oauth2_settings .APPLICATION_MODEL , on_delete = models .CASCADE )),
71- ('user' , models .ForeignKey (to = settings .AUTH_USER_MODEL , on_delete = models .CASCADE )),
89+ ('user' , models .ForeignKey (on_delete = django .db .models .deletion .CASCADE , related_name = 'oauth2_provider_refreshtoken' , to = settings .AUTH_USER_MODEL )),
90+ ('created' , models .DateTimeField (auto_now_add = True )),
91+ ('updated' , models .DateTimeField (auto_now = True )),
92+ ('revoked' , models .DateTimeField (null = True )),
7293 ],
7394 options = {
7495 'abstract' : False ,
7596 'swappable' : 'OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL' ,
97+ 'unique_together' : set ([("token" , "revoked" )]),
7698 },
7799 ),
100+ migrations .AddField (
101+ model_name = 'AccessToken' ,
102+ name = 'source_refresh_token' ,
103+ field = models .OneToOneField (blank = True , null = True , on_delete = django .db .models .deletion .SET_NULL , to = oauth2_settings .REFRESH_TOKEN_MODEL , related_name = "refreshed_access_token" ),
104+ ),
78105 ]
0 commit comments