|
|
- # 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)]
|