1
1
from django .conf import settings
2
+ import django .db .models .deletion
2
3
from django .db import migrations , models
3
4
4
5
import oauth2_provider .generators
7
8
8
9
9
10
class 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
+ """
11
20
dependencies = [
12
21
migrations .swappable_dependency (settings .AUTH_USER_MODEL )
13
22
]
@@ -16,14 +25,17 @@ class Migration(migrations.Migration):
16
25
migrations .CreateModel (
17
26
name = 'Application' ,
18
27
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 )),
20
29
('client_id' , models .CharField (default = oauth2_provider .generators .generate_client_id , unique = True , max_length = 100 , db_index = True )),
21
30
('redirect_uris' , models .TextField (help_text = 'Allowed URIs list, space separated' , blank = True )),
22
31
('client_type' , models .CharField (max_length = 32 , choices = [('confidential' , 'Confidential' ), ('public' , 'Public' )])),
23
32
('authorization_grant_type' , models .CharField (max_length = 32 , choices = [('authorization-code' , 'Authorization code' ), ('implicit' , 'Implicit' ), ('password' , 'Resource owner password-based' ), ('client-credentials' , 'Client credentials' )])),
24
33
('client_secret' , models .CharField (default = oauth2_provider .generators .generate_client_secret , max_length = 255 , db_index = True , blank = True )),
25
34
('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 )),
27
39
],
28
40
options = {
29
41
'abstract' : False ,
@@ -33,12 +45,16 @@ class Migration(migrations.Migration):
33
45
migrations .CreateModel (
34
46
name = 'AccessToken' ,
35
47
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 )),
38
50
('expires' , models .DateTimeField ()),
39
51
('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")),
42
58
],
43
59
options = {
44
60
'abstract' : False ,
@@ -48,13 +64,15 @@ class Migration(migrations.Migration):
48
64
migrations .CreateModel (
49
65
name = 'Grant' ,
50
66
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 )),
53
69
('expires' , models .DateTimeField ()),
54
70
('redirect_uri' , models .CharField (max_length = 255 )),
55
71
('scope' , models .TextField (blank = True )),
56
72
('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 )),
58
76
],
59
77
options = {
60
78
'abstract' : False ,
@@ -64,15 +82,24 @@ class Migration(migrations.Migration):
64
82
migrations .CreateModel (
65
83
name = 'RefreshToken' ,
66
84
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 )),
70
88
('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 )),
72
93
],
73
94
options = {
74
95
'abstract' : False ,
75
96
'swappable' : 'OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL' ,
97
+ 'unique_together' : set ([("token" , "revoked" )]),
76
98
},
77
99
),
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
+ ),
78
105
]
0 commit comments