You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
725 B

# Generated by Django 3.2.2 on 2021-05-21 09:15
import json
from django.db import migrations
def normalize_sms_values(apps, schema_editor):
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)]