authentik.sources.plex.migrations.0001_initial

 1# Generated by Django 3.2 on 2021-05-03 18:59
 2
 3import django.contrib.postgres.fields
 4import django.db.models.deletion
 5from django.db import migrations, models
 6
 7import authentik.lib.generators
 8
 9
10class Migration(migrations.Migration):
11    initial = True
12
13    dependencies = [
14        ("authentik_core", "0020_source_user_matching_mode"),
15    ]
16
17    operations = [
18        migrations.CreateModel(
19            name="PlexSource",
20            fields=[
21                (
22                    "source_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_core.source",
30                    ),
31                ),
32                (
33                    "client_id",
34                    models.TextField(
35                        default=authentik.lib.generators.generate_id,
36                        help_text="Client identifier used to talk to Plex.",
37                    ),
38                ),
39                (
40                    "allowed_servers",
41                    django.contrib.postgres.fields.ArrayField(
42                        base_field=models.TextField(),
43                        default=list,
44                        help_text=(
45                            "Which servers a user has to be a member of to be granted access. Empty"
46                            " list allows every server."
47                        ),
48                        size=None,
49                    ),
50                ),
51            ],
52            options={
53                "verbose_name": "Plex Source",
54                "verbose_name_plural": "Plex Sources",
55            },
56            bases=("authentik_core.source",),
57        ),
58        migrations.CreateModel(
59            name="PlexSourceConnection",
60            fields=[
61                (
62                    "usersourceconnection_ptr",
63                    models.OneToOneField(
64                        auto_created=True,
65                        on_delete=django.db.models.deletion.CASCADE,
66                        parent_link=True,
67                        primary_key=True,
68                        serialize=False,
69                        to="authentik_core.usersourceconnection",
70                    ),
71                ),
72                ("plex_token", models.TextField()),
73                ("identifier", models.TextField()),
74            ],
75            options={
76                "verbose_name": "User Plex Source Connection",
77                "verbose_name_plural": "User Plex Source Connections",
78            },
79            bases=("authentik_core.usersourceconnection",),
80        ),
81    ]
class Migration(django.db.migrations.migration.Migration):
11class Migration(migrations.Migration):
12    initial = True
13
14    dependencies = [
15        ("authentik_core", "0020_source_user_matching_mode"),
16    ]
17
18    operations = [
19        migrations.CreateModel(
20            name="PlexSource",
21            fields=[
22                (
23                    "source_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_core.source",
31                    ),
32                ),
33                (
34                    "client_id",
35                    models.TextField(
36                        default=authentik.lib.generators.generate_id,
37                        help_text="Client identifier used to talk to Plex.",
38                    ),
39                ),
40                (
41                    "allowed_servers",
42                    django.contrib.postgres.fields.ArrayField(
43                        base_field=models.TextField(),
44                        default=list,
45                        help_text=(
46                            "Which servers a user has to be a member of to be granted access. Empty"
47                            " list allows every server."
48                        ),
49                        size=None,
50                    ),
51                ),
52            ],
53            options={
54                "verbose_name": "Plex Source",
55                "verbose_name_plural": "Plex Sources",
56            },
57            bases=("authentik_core.source",),
58        ),
59        migrations.CreateModel(
60            name="PlexSourceConnection",
61            fields=[
62                (
63                    "usersourceconnection_ptr",
64                    models.OneToOneField(
65                        auto_created=True,
66                        on_delete=django.db.models.deletion.CASCADE,
67                        parent_link=True,
68                        primary_key=True,
69                        serialize=False,
70                        to="authentik_core.usersourceconnection",
71                    ),
72                ),
73                ("plex_token", models.TextField()),
74                ("identifier", models.TextField()),
75            ],
76            options={
77                "verbose_name": "User Plex Source Connection",
78                "verbose_name_plural": "User Plex Source Connections",
79            },
80            bases=("authentik_core.usersourceconnection",),
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_core', '0020_source_user_matching_mode')]
operations = [<CreateModel name='PlexSource', fields=[('source_ptr', <django.db.models.fields.related.OneToOneField>), ('client_id', <django.db.models.fields.TextField>), ('allowed_servers', <django.contrib.postgres.fields.array.ArrayField>)], options={'verbose_name': 'Plex Source', 'verbose_name_plural': 'Plex Sources'}, bases=('authentik_core.source',)>, <CreateModel name='PlexSourceConnection', fields=[('usersourceconnection_ptr', <django.db.models.fields.related.OneToOneField>), ('plex_token', <django.db.models.fields.TextField>), ('identifier', <django.db.models.fields.TextField>)], options={'verbose_name': 'User Plex Source Connection', 'verbose_name_plural': 'User Plex Source Connections'}, bases=('authentik_core.usersourceconnection',)>]