mirror of
https://github.com/healthchecks/healthchecks.git
synced 2024-11-21 15:17:57 +00:00
29 lines
821 B
Python
29 lines
821 B
Python
# Generated by Django 3.2.8 on 2021-10-21 09:30
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from django.apps.registry import Apps
|
|
from django.db import migrations
|
|
|
|
|
|
def fill_last_notify(apps: Apps, schema_editor: Any) -> None:
|
|
Channel = apps.get_model("api", "Channel")
|
|
Notification = apps.get_model("api", "Notification")
|
|
for channel in Channel.objects.filter(last_notify=None):
|
|
try:
|
|
n = Notification.objects.filter(channel=channel).latest()
|
|
channel.last_notify = n.created
|
|
channel.save()
|
|
except Notification.DoesNotExist:
|
|
pass
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("api", "0081_channel_last_notify"),
|
|
]
|
|
|
|
operations = [migrations.RunPython(fill_last_notify, migrations.RunPython.noop)]
|