Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-28 07:24:56

0001 """Drop `data.kind` from alarm configs.
0002 
0003 Alarms are snowflakes — each has its own Python module, keyed by
0004 entry_id. There is no shared "kind" library. The Entry row-level `kind`
0005 column remains `'alarm'` (the document kind). This strips `data.kind`
0006 from every alarm config row.
0007 
0008 Idempotent; reverse is a no-op.
0009 """
0010 from __future__ import annotations
0011 
0012 from django.db import migrations
0013 
0014 
0015 CONTEXT_NAME = 'swf-alarms'
0016 
0017 
0018 def drop_kind(apps, schema_editor):
0019     Entry = apps.get_model('remote_app', 'Entry')
0020     qs = Entry.objects.filter(context__name=CONTEXT_NAME, kind='alarm',
0021                               deleted_at__isnull=True)
0022     for e in qs:
0023         data = dict(e.data or {})
0024         if 'kind' in data:
0025             data.pop('kind', None)
0026             e.data = data
0027             e.save()
0028 
0029 
0030 def noop(apps, schema_editor):
0031     pass
0032 
0033 
0034 class Migration(migrations.Migration):
0035     dependencies = [('remote_app', '0004_purge_workinggroup')]
0036     operations = [migrations.RunPython(drop_kind, noop)]