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
700 B

# Generated by Django 3.0.1 on 2020-01-02 14:28
from django.db import migrations
def fill_last_errors(apps, schema_editor):
Channel = apps.get_model("api", "Channel")
Notification = apps.get_model("api", "Notification")
for ch in Channel.objects.all():
error = ""
try:
n = Notification.objects.filter(channel=ch).latest()
error = n.error
except Notification.DoesNotExist:
pass
ch.last_error = error
ch.save()
class Migration(migrations.Migration):
dependencies = [
("api", "0066_channel_last_error"),
]
operations = [migrations.RunPython(fill_last_errors, migrations.RunPython.noop)]