mirror of
https://github.com/healthchecks/healthchecks.git
synced 2024-11-21 15:17:57 +00:00
31 lines
840 B
Python
31 lines
840 B
Python
# Generated by Django 3.2.2 on 2021-05-21 09:15
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from typing import Any
|
|
|
|
from django.apps.registry import Apps
|
|
from django.db import migrations
|
|
|
|
|
|
def normalize_sms_values(apps: Apps, schema_editor: Any) -> None:
|
|
Channel = apps.get_model("api", "Channel")
|
|
for ch in Channel.objects.filter(kind="sms").only("value"):
|
|
if ch.value.startswith("{"):
|
|
doc = json.loads(ch.value)
|
|
phone_number = doc["value"]
|
|
else:
|
|
phone_number = ch.value
|
|
|
|
ch.value = json.dumps({"value": phone_number, "up": False, "down": True})
|
|
ch.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("api", "0077_auto_20210506_0755"),
|
|
]
|
|
|
|
operations = [migrations.RunPython(normalize_sms_values, migrations.RunPython.noop)]
|