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

25 lines
679 B
Python

# Generated by Django 2.1.3 on 2018-11-20 20:04
from __future__ import annotations
import json
from typing import Any
from django.apps.registry import Apps
from django.db import migrations
def combine_channel_names(apps: Apps, schema_editor: Any) -> None:
Channel = apps.get_model("api", "Channel")
for channel in Channel.objects.filter(kind="sms"):
if channel.value.startswith("{"):
doc = json.loads(channel.value)
channel.name = doc.get("label", "")
channel.save()
class Migration(migrations.Migration):
dependencies = [("api", "0043_channel_name")]
operations = [migrations.RunPython(combine_channel_names)]