authentik.policies.geoip.migrations.0001_initial

 1# Generated by Django 5.0.7 on 2024-07-16 11:23
 2
 3import django.contrib.postgres.fields
 4import django.db.models.deletion
 5import django_countries.fields
 6from django.db import migrations, models
 7
 8
 9class Migration(migrations.Migration):
10
11    initial = True
12
13    dependencies = [
14        ("authentik_policies", "0011_policybinding_failure_result_and_more"),
15    ]
16
17    operations = [
18        migrations.CreateModel(
19            name="GeoIPPolicy",
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                    "asns",
34                    django.contrib.postgres.fields.ArrayField(
35                        base_field=models.IntegerField(), blank=True, default=list, size=None
36                    ),
37                ),
38                (
39                    "countries",
40                    django_countries.fields.CountryField(blank=True, max_length=746, multiple=True),
41                ),
42            ],
43            options={
44                "verbose_name": "GeoIP Policy",
45                "verbose_name_plural": "GeoIP Policies",
46                "indexes": [
47                    models.Index(fields=["policy_ptr_id"], name="authentik_p_policy__5cc4a9_idx")
48                ],
49            },
50            bases=("authentik_policies.policy",),
51        ),
52    ]
class Migration(django.db.migrations.migration.Migration):
10class Migration(migrations.Migration):
11
12    initial = True
13
14    dependencies = [
15        ("authentik_policies", "0011_policybinding_failure_result_and_more"),
16    ]
17
18    operations = [
19        migrations.CreateModel(
20            name="GeoIPPolicy",
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                    "asns",
35                    django.contrib.postgres.fields.ArrayField(
36                        base_field=models.IntegerField(), blank=True, default=list, size=None
37                    ),
38                ),
39                (
40                    "countries",
41                    django_countries.fields.CountryField(blank=True, max_length=746, multiple=True),
42                ),
43            ],
44            options={
45                "verbose_name": "GeoIP Policy",
46                "verbose_name_plural": "GeoIP Policies",
47                "indexes": [
48                    models.Index(fields=["policy_ptr_id"], name="authentik_p_policy__5cc4a9_idx")
49                ],
50            },
51            bases=("authentik_policies.policy",),
52        ),
53    ]

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')]
operations = [<CreateModel name='GeoIPPolicy', fields=[('policy_ptr', <django.db.models.fields.related.OneToOneField>), ('asns', <django.contrib.postgres.fields.array.ArrayField>), ('countries', <django_countries.fields.CountryField>)], options={'verbose_name': 'GeoIP Policy', 'verbose_name_plural': 'GeoIP Policies', 'indexes': [<Index: fields=['policy_ptr_id'] name='authentik_p_policy__5cc4a9_idx'>]}, bases=('authentik_policies.policy',)>]