authentik.policies.expression.migrations.0002_auto_20200926_1156

 1# Generated by Django 3.1.1 on 2020-09-26 11:56
 2
 3from django.apps.registry import Apps
 4from django.db import migrations
 5from django.db.backends.base.schema import BaseDatabaseSchemaEditor
 6
 7
 8def remove_pb_flow_plan(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
 9    ExpressionPolicy = apps.get_model("authentik_policies_expression", "ExpressionPolicy")
10
11    db_alias = schema_editor.connection.alias
12
13    for policy in ExpressionPolicy.objects.using(db_alias).all():
14        policy.expression = policy.expression.replace("pb_flow_plan.", "context.")
15        policy.save()
16
17
18class Migration(migrations.Migration):
19    dependencies = [
20        ("authentik_policies_expression", "0001_initial"),
21    ]
22
23    operations = [
24        migrations.RunPython(remove_pb_flow_plan),
25    ]
def remove_pb_flow_plan( apps: django.apps.registry.Apps, schema_editor: django.db.backends.base.schema.BaseDatabaseSchemaEditor):
 9def remove_pb_flow_plan(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
10    ExpressionPolicy = apps.get_model("authentik_policies_expression", "ExpressionPolicy")
11
12    db_alias = schema_editor.connection.alias
13
14    for policy in ExpressionPolicy.objects.using(db_alias).all():
15        policy.expression = policy.expression.replace("pb_flow_plan.", "context.")
16        policy.save()
class Migration(django.db.migrations.migration.Migration):
19class Migration(migrations.Migration):
20    dependencies = [
21        ("authentik_policies_expression", "0001_initial"),
22    ]
23
24    operations = [
25        migrations.RunPython(remove_pb_flow_plan),
26    ]

The base class for all migrations.

Migration files will import this from django.db.migrations.Migration and subclass it as a class called Migration. It will have one or more of the following attributes:

  • operations: A list of Operation instances, probably from django.db.migrations.operations
  • dependencies: A list of tuples of (app_path, migration_name)
  • run_before: A list of tuples of (app_path, migration_name)
  • replaces: A list of migration_names

Note that all migrations come out of migrations and into the Loader or Graph as instances, having been initialized with their app label and name.

dependencies = [('authentik_policies_expression', '0001_initial')]
operations = [<RunPython <function remove_pb_flow_plan>>]