From 9f6f8e1b5556fa5caec933999afc23d1b6003cad Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 13 Dec 2020 15:15:20 +0100 Subject: [PATCH] outposts: update keys in outpost config --- .../migrations/0014_auto_20201213_1407.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 authentik/outposts/migrations/0014_auto_20201213_1407.py diff --git a/authentik/outposts/migrations/0014_auto_20201213_1407.py b/authentik/outposts/migrations/0014_auto_20201213_1407.py new file mode 100644 index 000000000..0f95e1416 --- /dev/null +++ b/authentik/outposts/migrations/0014_auto_20201213_1407.py @@ -0,0 +1,29 @@ +# Generated by Django 3.1.4 on 2020-12-13 14:07 + +from django.apps.registry import Apps +from django.db import migrations +from django.db.backends.base.schema import BaseDatabaseSchemaEditor + + +def update_config_prefix(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): + alias = schema_editor.connection.alias + Outpost = apps.get_model("authentik_outposts", "Outpost") + + for outpost in Outpost.objects.using(alias).all(): + config = outpost._config + for key in list(config): + if "passbook" in key: + new_key = key.replace("passbook", "authentik") + config[new_key] = config[key] + del config[key] + outpost._config = config + outpost.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("authentik_outposts", "0013_auto_20201203_2009"), + ] + + operations = [migrations.RunPython(update_config_prefix)]