Skip to content

Commit

Permalink
add migration for STATELESS event type
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Mar 1, 2022
1 parent f6a19be commit 009d823
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/argus/incident/migrations/0004_alter_event_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.11 on 2022-03-01 12:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('argus_incident', '0003_incident_level'),
]

operations = [
migrations.AlterField(
model_name='event',
name='type',
field=models.CharField(choices=[('STA', 'Incident start'), ('END', 'Incident end'), ('CLO', 'Close'), ('REO', 'Reopen'), ('ACK', 'Acknowledge'), ('OTH', 'Other'), ('LES', 'Stateless')], max_length=3),
),
]
22 changes: 22 additions & 0 deletions src/argus/incident/migrations/0005_auto_20220301_1400.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2.11 on 2022-03-01 13:00

from django.db import migrations


def update_event_type(apps, schema_editor):
# Change INCIDENT_START events for stateless incidents to STATELESS
Event = apps.get_model('argus_incident', 'Event')
for event in Event.objects.all():
if event.type == "STA" and event.incident.end_time == None:
event.type="LES"
event.save()

class Migration(migrations.Migration):

dependencies = [
('argus_incident', '0004_alter_event_type'),
]

operations = [
migrations.RunPython(update_event_type),
]

0 comments on commit 009d823

Please sign in to comment.