healthchecks_healthchecks/hc/api/migrations/0100_opsgenie_values.py
2023-10-25 18:12:12 +03:00

30 lines
748 B
Python

# Generated by Django 4.2.5 on 2023-09-11 13:06
from __future__ import annotations
import json
from typing import Any
from django.apps.registry import Apps
from django.db import migrations
def normalize_opsgenie_values(apps: Apps, schema_editor: Any) -> None:
Channel = apps.get_model("api", "Channel")
for ch in Channel.objects.filter(kind="opsgenie").only("value"):
if ch.value.startswith("{"):
continue
ch.value = json.dumps({"key": ch.value, "region": "us"})
ch.save()
class Migration(migrations.Migration):
dependencies = [
("api", "0099_alter_channel_disabled"),
]
operations = [
migrations.RunPython(normalize_opsgenie_values, migrations.RunPython.noop)
]