authentik.providers.oauth2.migrations.0040_accesstoken_family

Add refresh token families to access tokens.

This is separate from 0039 so the access token table is only locked for this migration, not while 0039 builds the refresh token indexes. Access tokens are short-lived, existing ones are not backfilled and expire without a family.

 1"""Add refresh token families to access tokens.
 2
 3This is separate from 0039 so the access token table is only locked for this migration, not
 4while 0039 builds the refresh token indexes. Access tokens are short-lived, existing ones are not
 5backfilled and expire without a family.
 6"""
 7
 8from django.db import migrations, models
 9
10
11class Migration(migrations.Migration):
12
13    dependencies = [
14        ("authentik_providers_oauth2", "0039_refresh_token_hash_family"),
15    ]
16
17    operations = [
18        migrations.AddField(
19            model_name="accesstoken",
20            name="family",
21            field=models.UUIDField(default=None, null=True),
22        ),
23        migrations.AddIndex(
24            model_name="accesstoken",
25            index=models.Index(
26                condition=models.Q(("family__isnull", False)),
27                fields=["family"],
28                name="authentik_p_at_family_idx",
29            ),
30        ),
31    ]
class Migration(django.db.migrations.migration.Migration):
12class Migration(migrations.Migration):
13
14    dependencies = [
15        ("authentik_providers_oauth2", "0039_refresh_token_hash_family"),
16    ]
17
18    operations = [
19        migrations.AddField(
20            model_name="accesstoken",
21            name="family",
22            field=models.UUIDField(default=None, null=True),
23        ),
24        migrations.AddIndex(
25            model_name="accesstoken",
26            index=models.Index(
27                condition=models.Q(("family__isnull", False)),
28                fields=["family"],
29                name="authentik_p_at_family_idx",
30            ),
31        ),
32    ]

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_providers_oauth2', '0039_refresh_token_hash_family')]
operations = [<AddField model_name='accesstoken', name='family', field=<django.db.models.fields.UUIDField>>, <AddIndex model_name='accesstoken', index=<Index: fields=['family'] name='authentik_p_at_family_idx' condition=(AND: ('family__isnull', False))>>]