Skip to content

Commit 000c44a

Browse files
committed
Fix the migrations to be two-step and allow upgrade from 0.7.2
1 parent 44a4157 commit 000c44a

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

oauth2_provider/migrations/0001_initial.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ class Migration(migrations.Migration):
2626
('authorization_grant_type', models.CharField(max_length=32, choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials')])),
2727
('client_secret', models.CharField(default=oauth2_provider.generators.generate_client_secret, max_length=255, db_index=True, blank=True)),
2828
('name', models.CharField(max_length=255, blank=True)),
29-
('skip_authorization', models.BooleanField(default=False)),
30-
('user', models.ForeignKey(related_name='oauth2_provider_application', to=settings.AUTH_USER_MODEL)),
29+
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
3130
],
3231
options={
3332
'abstract': False,
@@ -41,7 +40,7 @@ class Migration(migrations.Migration):
4140
('expires', models.DateTimeField()),
4241
('scope', models.TextField(blank=True)),
4342
('application', models.ForeignKey(to=oauth2_settings.APPLICATION_MODEL)),
44-
('user', models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True)),
43+
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
4544
],
4645
),
4746
migrations.CreateModel(
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from oauth2_provider.settings import oauth2_settings
5+
from django.db import models, migrations
6+
import oauth2_provider.validators
7+
import oauth2_provider.generators
8+
from django.conf import settings
9+
10+
11+
class Migration(migrations.Migration):
12+
13+
dependencies = [
14+
('oauth2_provider', '0001_initial'),
15+
]
16+
17+
operations = [
18+
migrations.AddField(
19+
model_name='Application',
20+
name='skip_authorization',
21+
field=models.BooleanField(default=False),
22+
preserve_default=True,
23+
),
24+
migrations.AlterField(
25+
model_name='Application',
26+
name='user',
27+
field=models.ForeignKey(related_name='oauth2_provider_application', to=settings.AUTH_USER_MODEL),
28+
preserve_default=True,
29+
),
30+
migrations.AlterField(
31+
model_name='AccessToken',
32+
name='user',
33+
field=models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True),
34+
preserve_default=True,
35+
),
36+
]

0 commit comments

Comments
 (0)