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

  1. # Generated by Django 3.0.1 on 2020-01-02 14:28
  2. from django.db import migrations
  3. def fill_last_errors(apps, schema_editor):
  4. Channel = apps.get_model("api", "Channel")
  5. Notification = apps.get_model("api", "Notification")
  6. for ch in Channel.objects.all():
  7. error = ""
  8. try:
  9. n = Notification.objects.filter(channel=ch).latest()
  10. error = n.error
  11. except Notification.DoesNotExist:
  12. pass
  13. ch.last_error = error
  14. ch.save()
  15. class Migration(migrations.Migration):
  16. dependencies = [
  17. ("api", "0066_channel_last_error"),
  18. ]
  19. operations = [migrations.RunPython(fill_last_errors, migrations.RunPython.noop)]