authentik.enterprise.policies.unique_password.migrations.0001_initial

 1# Generated by Django 5.0.13 on 2025-03-26 23:02
 2
 3import django.db.models.deletion
 4from django.conf import settings
 5from django.db import migrations, models
 6
 7
 8class Migration(migrations.Migration):
 9
10    initial = True
11
12    dependencies = [
13        ("authentik_policies", "0011_policybinding_failure_result_and_more"),
14        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15    ]
16
17    operations = [
18        migrations.CreateModel(
19            name="UniquePasswordPolicy",
20            fields=[
21                (
22                    "policy_ptr",
23                    models.OneToOneField(
24                        auto_created=True,
25                        on_delete=django.db.models.deletion.CASCADE,
26                        parent_link=True,
27                        primary_key=True,
28                        serialize=False,
29                        to="authentik_policies.policy",
30                    ),
31                ),
32                (
33                    "password_field",
34                    models.TextField(
35                        default="password",
36                        help_text="Field key to check, field keys defined in Prompt stages are available.",
37                    ),
38                ),
39                (
40                    "num_historical_passwords",
41                    models.PositiveIntegerField(
42                        default=1, help_text="Number of passwords to check against."
43                    ),
44                ),
45            ],
46            options={
47                "verbose_name": "Password Uniqueness Policy",
48                "verbose_name_plural": "Password Uniqueness Policies",
49                "indexes": [
50                    models.Index(fields=["policy_ptr_id"], name="authentik_p_policy__f559aa_idx")
51                ],
52            },
53            bases=("authentik_policies.policy",),
54        ),
55        migrations.CreateModel(
56            name="UserPasswordHistory",
57            fields=[
58                (
59                    "id",
60                    models.AutoField(
61                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
62                    ),
63                ),
64                ("old_password", models.CharField(max_length=128)),
65                ("created_at", models.DateTimeField(auto_now_add=True)),
66                ("hibp_prefix_sha1", models.CharField(max_length=5)),
67                ("hibp_pw_hash", models.TextField()),
68                (
69                    "user",
70                    models.ForeignKey(
71                        on_delete=django.db.models.deletion.CASCADE,
72                        related_name="old_passwords",
73                        to=settings.AUTH_USER_MODEL,
74                    ),
75                ),
76            ],
77            options={
78                "verbose_name": "User Password History",
79            },
80        ),
81    ]
class Migration(django.db.migrations.migration.Migration):
 9class Migration(migrations.Migration):
10
11    initial = True
12
13    dependencies = [
14        ("authentik_policies", "0011_policybinding_failure_result_and_more"),
15        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
16    ]
17
18    operations = [
19        migrations.CreateModel(
20            name="UniquePasswordPolicy",
21            fields=[
22                (
23                    "policy_ptr",
24                    models.OneToOneField(
25                        auto_created=True,
26                        on_delete=django.db.models.deletion.CASCADE,
27                        parent_link=True,
28                        primary_key=True,
29                        serialize=False,
30                        to="authentik_policies.policy",
31                    ),
32                ),
33                (
34                    "password_field",
35                    models.TextField(
36                        default="password",
37                        help_text="Field key to check, field keys defined in Prompt stages are available.",
38                    ),
39                ),
40                (
41                    "num_historical_passwords",
42                    models.PositiveIntegerField(
43                        default=1, help_text="Number of passwords to check against."
44                    ),
45                ),
46            ],
47            options={
48                "verbose_name": "Password Uniqueness Policy",
49                "verbose_name_plural": "Password Uniqueness Policies",
50                "indexes": [
51                    models.Index(fields=["policy_ptr_id"], name="authentik_p_policy__f559aa_idx")
52                ],
53            },
54            bases=("authentik_policies.policy",),
55        ),
56        migrations.CreateModel(
57            name="UserPasswordHistory",
58            fields=[
59                (
60                    "id",
61                    models.AutoField(
62                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
63                    ),
64                ),
65                ("old_password", models.CharField(max_length=128)),
66                ("created_at", models.DateTimeField(auto_now_add=True)),
67                ("hibp_prefix_sha1", models.CharField(max_length=5)),
68                ("hibp_pw_hash", models.TextField()),
69                (
70                    "user",
71                    models.ForeignKey(
72                        on_delete=django.db.models.deletion.CASCADE,
73                        related_name="old_passwords",
74                        to=settings.AUTH_USER_MODEL,
75                    ),
76                ),
77            ],
78            options={
79                "verbose_name": "User Password History",
80            },
81        ),
82    ]

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.

initial = True
dependencies = [('authentik_policies', '0011_policybinding_failure_result_and_more'), ('authentik_core', '__first__')]
operations = [<CreateModel name='UniquePasswordPolicy', fields=[('policy_ptr', <django.db.models.fields.related.OneToOneField>), ('password_field', <django.db.models.fields.TextField>), ('num_historical_passwords', <django.db.models.fields.PositiveIntegerField>)], options={'verbose_name': 'Password Uniqueness Policy', 'verbose_name_plural': 'Password Uniqueness Policies', 'indexes': [<Index: fields=['policy_ptr_id'] name='authentik_p_policy__f559aa_idx'>]}, bases=('authentik_policies.policy',)>, <CreateModel name='UserPasswordHistory', fields=[('id', <django.db.models.fields.AutoField>), ('old_password', <django.db.models.fields.CharField>), ('created_at', <django.db.models.fields.DateTimeField>), ('hibp_prefix_sha1', <django.db.models.fields.CharField>), ('hibp_pw_hash', <django.db.models.fields.TextField>), ('user', <django.db.models.fields.related.ForeignKey>)], options={'verbose_name': 'User Password History'}>]