authentik.tasks.schedules.migrations.0001_initial
1# Generated by Django 5.1.11 on 2025-07-07 16:01 2 3import django.db.models.deletion 4import django_dramatiq_postgres.models 5import pgtrigger.compiler 6import pgtrigger.migrations 7import uuid 8from django.db import migrations, models 9 10 11class Migration(migrations.Migration): 12 13 initial = True 14 15 dependencies = [ 16 ("contenttypes", "0002_remove_content_type_name"), 17 ] 18 19 operations = [ 20 migrations.CreateModel( 21 name="Schedule", 22 fields=[ 23 ( 24 "id", 25 models.UUIDField( 26 default=uuid.uuid4, editable=False, primary_key=True, serialize=False 27 ), 28 ), 29 ( 30 "actor_name", 31 models.TextField(editable=False, help_text="Dramatiq actor to call"), 32 ), 33 ("args", models.BinaryField(help_text="Args to send to the actor")), 34 ("kwargs", models.BinaryField(help_text="Kwargs to send to the actor")), 35 ("options", models.BinaryField(help_text="Options to send to the actor")), 36 ( 37 "crontab", 38 models.TextField( 39 help_text="When to schedule tasks", 40 validators=[django_dramatiq_postgres.models.validate_crontab], 41 ), 42 ), 43 ("paused", models.BooleanField(default=False, help_text="Pause this schedule")), 44 ("next_run", models.DateTimeField(auto_now_add=True)), 45 ( 46 "identifier", 47 models.TextField( 48 editable=False, 49 help_text="Unique schedule identifier", 50 null=True, 51 unique=True, 52 ), 53 ), 54 ( 55 "_uid", 56 models.TextField(blank=True, help_text="User schedule identifier", null=True), 57 ), 58 ("rel_obj_id", models.TextField(null=True)), 59 ( 60 "rel_obj_content_type", 61 models.ForeignKey( 62 null=True, 63 on_delete=django.db.models.deletion.CASCADE, 64 to="contenttypes.contenttype", 65 ), 66 ), 67 ], 68 options={ 69 "verbose_name": "Schedule", 70 "verbose_name_plural": "Schedules", 71 "permissions": [("send_schedule", "Manually trigger a schedule")], 72 "abstract": False, 73 "default_permissions": ("change", "view"), 74 "indexes": [ 75 models.Index( 76 fields=["rel_obj_content_type", "rel_obj_id"], 77 name="authentik_t_rel_obj_575af2_idx", 78 ) 79 ], 80 }, 81 ), 82 pgtrigger.migrations.AddTrigger( 83 model_name="schedule", 84 trigger=pgtrigger.compiler.Trigger( 85 name="set_next_run_on_paused", 86 sql=pgtrigger.compiler.UpsertTriggerSql( 87 condition='WHEN (NEW."paused" AND NOT OLD."paused")', 88 func="\n NEW.next_run = to_timestamp(0);\n RETURN NEW;\n ", 89 hash="7fe580a86de70723522cfcbac712785984000f92", 90 operation="UPDATE", 91 pgid="pgtrigger_set_next_run_on_paused_95c6d", 92 table="authentik_tasks_schedules_schedule", 93 when="BEFORE", 94 ), 95 ), 96 ), 97 ]
class
Migration(django.db.migrations.migration.Migration):
12class Migration(migrations.Migration): 13 14 initial = True 15 16 dependencies = [ 17 ("contenttypes", "0002_remove_content_type_name"), 18 ] 19 20 operations = [ 21 migrations.CreateModel( 22 name="Schedule", 23 fields=[ 24 ( 25 "id", 26 models.UUIDField( 27 default=uuid.uuid4, editable=False, primary_key=True, serialize=False 28 ), 29 ), 30 ( 31 "actor_name", 32 models.TextField(editable=False, help_text="Dramatiq actor to call"), 33 ), 34 ("args", models.BinaryField(help_text="Args to send to the actor")), 35 ("kwargs", models.BinaryField(help_text="Kwargs to send to the actor")), 36 ("options", models.BinaryField(help_text="Options to send to the actor")), 37 ( 38 "crontab", 39 models.TextField( 40 help_text="When to schedule tasks", 41 validators=[django_dramatiq_postgres.models.validate_crontab], 42 ), 43 ), 44 ("paused", models.BooleanField(default=False, help_text="Pause this schedule")), 45 ("next_run", models.DateTimeField(auto_now_add=True)), 46 ( 47 "identifier", 48 models.TextField( 49 editable=False, 50 help_text="Unique schedule identifier", 51 null=True, 52 unique=True, 53 ), 54 ), 55 ( 56 "_uid", 57 models.TextField(blank=True, help_text="User schedule identifier", null=True), 58 ), 59 ("rel_obj_id", models.TextField(null=True)), 60 ( 61 "rel_obj_content_type", 62 models.ForeignKey( 63 null=True, 64 on_delete=django.db.models.deletion.CASCADE, 65 to="contenttypes.contenttype", 66 ), 67 ), 68 ], 69 options={ 70 "verbose_name": "Schedule", 71 "verbose_name_plural": "Schedules", 72 "permissions": [("send_schedule", "Manually trigger a schedule")], 73 "abstract": False, 74 "default_permissions": ("change", "view"), 75 "indexes": [ 76 models.Index( 77 fields=["rel_obj_content_type", "rel_obj_id"], 78 name="authentik_t_rel_obj_575af2_idx", 79 ) 80 ], 81 }, 82 ), 83 pgtrigger.migrations.AddTrigger( 84 model_name="schedule", 85 trigger=pgtrigger.compiler.Trigger( 86 name="set_next_run_on_paused", 87 sql=pgtrigger.compiler.UpsertTriggerSql( 88 condition='WHEN (NEW."paused" AND NOT OLD."paused")', 89 func="\n NEW.next_run = to_timestamp(0);\n RETURN NEW;\n ", 90 hash="7fe580a86de70723522cfcbac712785984000f92", 91 operation="UPDATE", 92 pgid="pgtrigger_set_next_run_on_paused_95c6d", 93 table="authentik_tasks_schedules_schedule", 94 when="BEFORE", 95 ), 96 ), 97 ), 98 ]
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.
operations =
[<CreateModel name='Schedule', fields=[('id', <django.db.models.fields.UUIDField>), ('actor_name', <django.db.models.fields.TextField>), ('args', <django.db.models.fields.BinaryField>), ('kwargs', <django.db.models.fields.BinaryField>), ('options', <django.db.models.fields.BinaryField>), ('crontab', <django.db.models.fields.TextField>), ('paused', <django.db.models.fields.BooleanField>), ('next_run', <django.db.models.fields.DateTimeField>), ('identifier', <django.db.models.fields.TextField>), ('_uid', <django.db.models.fields.TextField>), ('rel_obj_id', <django.db.models.fields.TextField>), ('rel_obj_content_type', <django.db.models.fields.related.ForeignKey>)], options={'verbose_name': 'Schedule', 'verbose_name_plural': 'Schedules', 'permissions': [('send_schedule', 'Manually trigger a schedule')], 'abstract': False, 'default_permissions': ('change', 'view'), 'indexes': [<Index: fields=['rel_obj_content_type', 'rel_obj_id'] name='authentik_t_rel_obj_575af2_idx'>]}>, <AddTrigger model_name='schedule', trigger=<pgtrigger.compiler.Trigger object>>]