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.

24 lines
705 B

  1. # Generated by Django 3.2.8 on 2021-10-21 09:30
  2. from django.db import migrations
  3. def fill_last_notify(apps, schema_editor):
  4. Channel = apps.get_model("api", "Channel")
  5. Notification = apps.get_model("api", "Notification")
  6. for channel in Channel.objects.filter(last_notify=None):
  7. try:
  8. n = Notification.objects.filter(channel=channel).latest()
  9. channel.last_notify = n.created
  10. channel.save()
  11. except Notification.DoesNotExist:
  12. pass
  13. class Migration(migrations.Migration):
  14. dependencies = [
  15. ("api", "0081_channel_last_notify"),
  16. ]
  17. operations = [migrations.RunPython(fill_last_notify, migrations.RunPython.noop)]