# Generated by Django 5.2.8 on 2025-11-29 17:00

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('schedule', '0020_add_eventplugin_offset'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='GlobalEventPlugin',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('trigger', models.CharField(choices=[('before_start', 'Before Start'), ('at_start', 'At Start'), ('after_start', 'After Start'), ('after_end', 'After End'), ('on_complete', 'When Completed'), ('on_cancel', 'When Canceled')], default='at_start', help_text='When this plugin should execute for each event', max_length=20)),
                ('offset_minutes', models.PositiveIntegerField(default=0, help_text='Minutes offset from trigger time')),
                ('is_active', models.BooleanField(default=True, help_text='Whether this rule is active')),
                ('execution_order', models.PositiveSmallIntegerField(default=0, help_text='Order of execution (lower numbers run first)')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_global_event_plugins', to=settings.AUTH_USER_MODEL)),
                ('plugin_installation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='global_event_rules', to='schedule.plugininstallation')),
            ],
            options={
                'ordering': ['execution_order', 'created_at'],
                'unique_together': {('plugin_installation', 'trigger', 'offset_minutes')},
            },
        ),
    ]
