Skip to content

Commit 0eacfc9

Browse files
committed
Adjust testproj migrations to oauth-toolkit v1.3+
1 parent 6f3a16f commit 0eacfc9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

testproj/users/migrations/0002_setup_oauth2_apps.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Generated by Django 2.1.3 on 2018-12-19 07:57
2+
import pkg_resources
23
from django.conf import settings
34
from django.db import migrations
45

@@ -27,10 +28,16 @@ def add_oauth_apps(apps, schema_editor):
2728
Application.objects.get_or_create(client_id=app['client_id'], defaults=app)
2829

2930

31+
def get_oauth_dependency():
32+
oauth_version = pkg_resources.get_distribution('django-oauth-toolkit').version.split('.')[:2]
33+
# 1.1 and 1.2 are before squasing migrations into 0001_initial
34+
return '0006_auto_20171214_2232' if oauth_version in (('1', '1'), ('1', '2')) else '0001_initial'
35+
36+
3037
class Migration(migrations.Migration):
3138
dependencies = [
3239
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
33-
('oauth2_provider', '0006_auto_20171214_2232'),
40+
('oauth2_provider', get_oauth_dependency()),
3441
('users', '0001_create_admin_user'),
3542
]
3643

0 commit comments

Comments
 (0)