authentik.providers.saml.migrations.0006_remove_samlprovider_name

 1# Generated by Django 3.1.2 on 2020-10-03 17:37
 2
 3from django.apps.registry import Apps
 4from django.db import migrations
 5from django.db.backends.base.schema import BaseDatabaseSchemaEditor
 6
 7
 8def update_name_temp(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
 9    SAMLProvider = apps.get_model("authentik_providers_saml", "SAMLProvider")
10    db_alias = schema_editor.connection.alias
11
12    for provider in SAMLProvider.objects.using(db_alias).all():
13        provider.name_temp = provider.name
14        provider.save()
15
16
17class Migration(migrations.Migration):
18    dependencies = [
19        ("authentik_core", "0011_provider_name_temp"),
20        ("authentik_providers_saml", "0005_remove_samlprovider_processor_path"),
21    ]
22
23    operations = [
24        migrations.RunPython(update_name_temp),
25        migrations.RemoveField(
26            model_name="samlprovider",
27            name="name",
28        ),
29    ]
def update_name_temp( apps: django.apps.registry.Apps, schema_editor: django.db.backends.base.schema.BaseDatabaseSchemaEditor):
 9def update_name_temp(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
10    SAMLProvider = apps.get_model("authentik_providers_saml", "SAMLProvider")
11    db_alias = schema_editor.connection.alias
12
13    for provider in SAMLProvider.objects.using(db_alias).all():
14        provider.name_temp = provider.name
15        provider.save()
class Migration(django.db.migrations.migration.Migration):
18class Migration(migrations.Migration):
19    dependencies = [
20        ("authentik_core", "0011_provider_name_temp"),
21        ("authentik_providers_saml", "0005_remove_samlprovider_processor_path"),
22    ]
23
24    operations = [
25        migrations.RunPython(update_name_temp),
26        migrations.RemoveField(
27            model_name="samlprovider",
28            name="name",
29        ),
30    ]

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_core', '0011_provider_name_temp'), ('authentik_providers_saml', '0005_remove_samlprovider_processor_path')]
operations = [<RunPython <function update_name_temp>>, <RemoveField model_name='samlprovider', name='name'>]