From b53c7a624bae487d251b01ddf50bd201ab2fb95c Mon Sep 17 00:00:00 2001 From: Adarnof Date: Tue, 27 Mar 2018 08:23:21 -0400 Subject: [PATCH] Use queryset delete to purge non-refreshable tokens. --- .../authentication/migrations/0015_user_profiles.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/allianceauth/authentication/migrations/0015_user_profiles.py b/allianceauth/authentication/migrations/0015_user_profiles.py index 7ba696b6..592ba0e8 100644 --- a/allianceauth/authentication/migrations/0015_user_profiles.py +++ b/allianceauth/authentication/migrations/0015_user_profiles.py @@ -96,6 +96,11 @@ def create_blue_group(apps, schema_editor): pass +def purge_tokens(apps, schema_editor): + Token = apps.get_model('esi', 'Token') + Token.objects.filter(refresh_token__isnull=True).delete() + + def populate_ownerships(apps, schema_editor): Token = apps.get_model('esi', 'Token') CharacterOwnership = apps.get_model('authentication', 'CharacterOwnership') @@ -221,6 +226,7 @@ class Migration(migrations.Migration): migrations.RunPython(create_guest_state, migrations.RunPython.noop), migrations.RunPython(create_member_state, create_member_group), migrations.RunPython(create_blue_state, create_blue_group), + migrations.RunPython(purge_tokens, migrations.RunPython.noop), migrations.RunPython(populate_ownerships, migrations.RunPython.noop), migrations.RunPython(create_profiles, recreate_authservicesinfo), migrations.RemoveField(