1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- # Generated by Django 3.1.7 on 2021-03-14 20:22
- from django.db import migrations, models
- import django.db.models.deletion
- def forwards_func(apps, schema_editor):
- Notification = apps.get_model("alerts", "Notification")
- ProjectAlert = apps.get_model("alerts", "ProjectAlert")
- for notification in Notification.objects.all():
- notification.project_alert = ProjectAlert.objects.filter(
- project=notification.project
- ).first()
- notification.save()
- def reverse_func(apps, schema_editor):
- pass
- class Migration(migrations.Migration):
- dependencies = [
- ("alerts", "0001_initial"),
- ]
- operations = [
- migrations.AddField(
- model_name="notification",
- name="project_alert",
- field=models.ForeignKey(
- null=True,
- on_delete=django.db.models.deletion.CASCADE,
- to="alerts.projectalert",
- ),
- preserve_default=False,
- ),
- migrations.RunPython(forwards_func, reverse_func),
- migrations.AlterField(
- model_name="notification",
- name="project_alert",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- to="alerts.projectalert",
- ),
- preserve_default=False,
- ),
- migrations.RemoveField(
- model_name="notification",
- name="project",
- ),
- migrations.CreateModel(
- name="AlertRecipient",
- fields=[
- (
- "id",
- models.AutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- (
- "recipient_type",
- models.CharField(
- choices=[("email", "Email"), ("webhook", "Webhook")],
- max_length=16,
- ),
- ),
- ("url", models.URLField(blank=True)),
- (
- "alert",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- to="alerts.projectalert",
- ),
- ),
- ],
- ),
- ]
|