Skip to content

Commit a123285

Browse files
Only run hasher migration on non-swapped models.
1 parent 025cd1b commit a123285

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

oauth2_provider/migrations/0006_alter_application_client_secret.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
from django.db import migrations
2-
from django.contrib.auth.hashers import identify_hasher, make_password
3-
import logging
42
import oauth2_provider.generators
53
import oauth2_provider.models
6-
4+
from oauth2_provider.settings import oauth2_settings
75

86
def forwards_func(apps, schema_editor):
97
"""
108
Forward migration touches every application.client_secret which will cause it to be hashed if not already the case.
119
"""
12-
Application = apps.get_model('oauth2_provider', 'application')
13-
applications = Application.objects.all()
14-
for application in applications:
15-
application.save(update_fields=['client_secret'])
10+
if oauth2_settings.APPLICATION_MODEL == 'oauth2_provider.Application':
11+
Application = apps.get_model('oauth2_provider', 'application')
12+
applications = Application.objects.all()
13+
for application in applications:
14+
application.save(update_fields=['client_secret'])
1615

1716

1817
class Migration(migrations.Migration):

0 commit comments

Comments
 (0)