healthchecks_healthchecks/hc/api/migrations/0104_fill_notification_code.py
Pēteris Caune 26a57343b1
Add a data migration to fill null api_notification.code values
Using model's default didn't quite work, as Django tried to use
the same UUID for all rows.
2024-05-17 10:43:46 +03:00

25 lines
594 B
Python

# Generated by Django 5.0.4 on 2024-05-17 07:39
from __future__ import annotations
import uuid
from typing import Any
from django.apps.registry import Apps
from django.db import migrations
def fill_code(apps: Apps, schema_editor: Any) -> None:
Notification = apps.get_model("api", "Notification")
for n in Notification.objects.filter(code=None):
n.code = uuid.uuid4()
n.save()
class Migration(migrations.Migration):
dependencies = [
("api", "0103_check_badge_key"),
]
operations = [migrations.RunPython(fill_code, migrations.RunPython.noop)]