healthchecks/hc/api/migrations/0044_auto_20181120_2004.py
2019-05-15 14:27:50 +03:00

22 lines
564 B
Python

# Generated by Django 2.1.3 on 2018-11-20 20:04
import json
from django.db import migrations
def combine_channel_names(apps, schema_editor):
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)]