|
| 1 | +# Generated by Django 5.2.11 on 2026-06-16 12:29 |
| 2 | + |
| 3 | +import django.core.validators |
| 4 | +from django.db import migrations |
| 5 | +from django.db import models |
| 6 | +from django.db.models import F |
| 7 | + |
| 8 | + |
| 9 | +class Migration(migrations.Migration): |
| 10 | + |
| 11 | + dependencies = [ |
| 12 | + ("vulnerabilities", "0136_advisorysetmember_unique_advisory_per_set"), |
| 13 | + ] |
| 14 | + |
| 15 | + def convert_hours_to_minutes(apps, schema_editor): |
| 16 | + PipelineSchedule = apps.get_model("vulnerabilities", "PipelineSchedule") |
| 17 | + PipelineSchedule.objects.update(run_interval=F("run_interval") * 60) |
| 18 | + |
| 19 | + def revert_convert_hours_to_minutes(apps, schema_editor): |
| 20 | + PipelineSchedule = apps.get_model("vulnerabilities", "PipelineSchedule") |
| 21 | + for schedule in PipelineSchedule.objects.all(): |
| 22 | + schedule.run_interval = min(8760, max(1, schedule.run_interval // 60)) |
| 23 | + schedule.save(update_fields=["run_interval"]) |
| 24 | + |
| 25 | + operations = [ |
| 26 | + migrations.AlterField( |
| 27 | + model_name="pipelineschedule", |
| 28 | + name="run_interval", |
| 29 | + field=models.PositiveSmallIntegerField( |
| 30 | + default=1440, |
| 31 | + help_text="Number of minutes to wait between run of this pipeline.", |
| 32 | + validators=[ |
| 33 | + django.core.validators.MinValueValidator( |
| 34 | + 5, message="Interval must be at least 5 minutes." |
| 35 | + ), |
| 36 | + django.core.validators.MaxValueValidator( |
| 37 | + 43200, message="Interval must be at most 43200 minutes (i.e 30 days)." |
| 38 | + ), |
| 39 | + ], |
| 40 | + ), |
| 41 | + ), |
| 42 | + migrations.RunPython( |
| 43 | + convert_hours_to_minutes, |
| 44 | + revert_convert_hours_to_minutes, |
| 45 | + ), |
| 46 | + ] |
0 commit comments