authentik.stages.consent.migrations.0002_auto_20200720_0941

 1# Generated by Django 3.0.8 on 2020-07-20 09:41
 2
 3import django.db.models.deletion
 4from django.conf import settings
 5from django.db import migrations, models
 6
 7import authentik.core.models
 8import authentik.lib.utils.time
 9
10
11class Migration(migrations.Migration):
12    dependencies = [
13        ("authentik_core", "0006_auto_20200709_1608"),
14        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15        ("authentik_stages_consent", "0001_initial"),
16    ]
17
18    operations = [
19        migrations.AddField(
20            model_name="consentstage",
21            name="consent_expire_in",
22            field=models.TextField(
23                default="weeks=4",
24                help_text=(
25                    "Offset after which consent expires. (Format: hours=1;minutes=2;seconds=3)."
26                ),
27                validators=[authentik.lib.utils.time.timedelta_string_validator],
28                verbose_name="Consent expires in",
29            ),
30        ),
31        migrations.AddField(
32            model_name="consentstage",
33            name="mode",
34            field=models.TextField(
35                choices=[
36                    ("always_require", "Always Require"),
37                    ("permanent", "Permanent"),
38                    ("expiring", "Expiring"),
39                ],
40                default="always_require",
41            ),
42        ),
43        migrations.CreateModel(
44            name="UserConsent",
45            fields=[
46                (
47                    "id",
48                    models.AutoField(
49                        auto_created=True,
50                        primary_key=True,
51                        serialize=False,
52                        verbose_name="ID",
53                    ),
54                ),
55                (
56                    "expires",
57                    models.DateTimeField(default=authentik.core.models.default_token_duration),
58                ),
59                ("expiring", models.BooleanField(default=True)),
60                (
61                    "application",
62                    models.ForeignKey(
63                        on_delete=django.db.models.deletion.CASCADE,
64                        to="authentik_core.Application",
65                    ),
66                ),
67                (
68                    "user",
69                    models.ForeignKey(
70                        on_delete=django.db.models.deletion.CASCADE,
71                        related_name="ak_consent",
72                        to=settings.AUTH_USER_MODEL,
73                    ),
74                ),
75            ],
76            options={
77                "verbose_name": "User Consent",
78                "verbose_name_plural": "User Consents",
79                "unique_together": {("user", "application")},
80            },
81        ),
82    ]
class Migration(django.db.migrations.migration.Migration):
12class Migration(migrations.Migration):
13    dependencies = [
14        ("authentik_core", "0006_auto_20200709_1608"),
15        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
16        ("authentik_stages_consent", "0001_initial"),
17    ]
18
19    operations = [
20        migrations.AddField(
21            model_name="consentstage",
22            name="consent_expire_in",
23            field=models.TextField(
24                default="weeks=4",
25                help_text=(
26                    "Offset after which consent expires. (Format: hours=1;minutes=2;seconds=3)."
27                ),
28                validators=[authentik.lib.utils.time.timedelta_string_validator],
29                verbose_name="Consent expires in",
30            ),
31        ),
32        migrations.AddField(
33            model_name="consentstage",
34            name="mode",
35            field=models.TextField(
36                choices=[
37                    ("always_require", "Always Require"),
38                    ("permanent", "Permanent"),
39                    ("expiring", "Expiring"),
40                ],
41                default="always_require",
42            ),
43        ),
44        migrations.CreateModel(
45            name="UserConsent",
46            fields=[
47                (
48                    "id",
49                    models.AutoField(
50                        auto_created=True,
51                        primary_key=True,
52                        serialize=False,
53                        verbose_name="ID",
54                    ),
55                ),
56                (
57                    "expires",
58                    models.DateTimeField(default=authentik.core.models.default_token_duration),
59                ),
60                ("expiring", models.BooleanField(default=True)),
61                (
62                    "application",
63                    models.ForeignKey(
64                        on_delete=django.db.models.deletion.CASCADE,
65                        to="authentik_core.Application",
66                    ),
67                ),
68                (
69                    "user",
70                    models.ForeignKey(
71                        on_delete=django.db.models.deletion.CASCADE,
72                        related_name="ak_consent",
73                        to=settings.AUTH_USER_MODEL,
74                    ),
75                ),
76            ],
77            options={
78                "verbose_name": "User Consent",
79                "verbose_name_plural": "User Consents",
80                "unique_together": {("user", "application")},
81            },
82        ),
83    ]

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', '0006_auto_20200709_1608'), ('authentik_core', '__first__'), ('authentik_stages_consent', '0001_initial')]
operations = [<AddField model_name='consentstage', name='consent_expire_in', field=<django.db.models.fields.TextField>>, <AddField model_name='consentstage', name='mode', field=<django.db.models.fields.TextField>>, <CreateModel name='UserConsent', fields=[('id', <django.db.models.fields.AutoField>), ('expires', <django.db.models.fields.DateTimeField>), ('expiring', <django.db.models.fields.BooleanField>), ('application', <django.db.models.fields.related.ForeignKey>), ('user', <django.db.models.fields.related.ForeignKey>)], options={'verbose_name': 'User Consent', 'verbose_name_plural': 'User Consents', 'unique_together': {('user', 'application')}}>]