# Generated by Django 5.2.17 on 2026-09-24 14:10 import django.db.models.deletion from django.db import migrations, models import infrasynth.shared.enums class Migration(migrations.Migration): initial = True dependencies = [ ("tenancy", "0001_initial"), ] operations = [ migrations.CreateModel( name="NotificationTemplate", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("slug", models.SlugField(max_length=100)), ("name", models.CharField(max_length=200)), ("channel", models.CharField(choices=infrasynth.shared.enums.ChannelType.choices, max_length=20)), ("subject_template", models.CharField(max_length=500)), ("body_template", models.TextField()), ("is_html", models.BooleanField(default=False)), ("namespace", models.CharField(blank=True, default="", max_length=100)), ("metadata", models.JSONField(default=dict)), ( "tenant", models.ForeignKey( blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tenancy.tenant", ), ), ], options={ "db_table": "notifications_template", }, ), migrations.CreateModel( name="NotificationDispatch", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("recipient", models.CharField(max_length=255)), ("channel", models.CharField(choices=infrasynth.shared.enums.ChannelType.choices, max_length=20)), ("subject", models.CharField(max_length=500)), ("body", models.TextField()), ( "status", models.CharField( choices=[ ("pending", "Pending"), ("sent", "Sent"), ("failed", "Failed"), ("retrying", "Retrying"), ], default="pending", max_length=20, ), ), ("error_message", models.TextField(blank=True, default="")), ("attempt", models.PositiveSmallIntegerField(default=0)), ("next_retry_at", models.DateTimeField(blank=True, null=True)), ("context_snapshot", models.JSONField(blank=True, default=dict)), ("created_at", models.DateTimeField(auto_now_add=True)), ("completed_at", models.DateTimeField(blank=True, null=True)), ("request_id", models.UUIDField(blank=True, null=True)), ( "tenant", models.ForeignKey( editable=False, on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tenancy.tenant", ), ), ( "template", models.ForeignKey( blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="dispatches", to="infrasynth_notifications.notificationtemplate", ), ), ], options={ "db_table": "notifications_dispatch", }, ), migrations.CreateModel( name="ChannelConfig", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("slug", models.SlugField(max_length=100)), ("channel_type", models.CharField(choices=infrasynth.shared.enums.ChannelType.choices, max_length=20)), ("display_name", models.CharField(max_length=200)), ("config", models.JSONField(default=dict)), ("is_active", models.BooleanField(default=True)), ("priority", models.PositiveSmallIntegerField(default=0)), ( "tenant", models.ForeignKey( editable=False, on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tenancy.tenant", ), ), ], options={ "db_table": "notifications_channel_config", "constraints": [ models.UniqueConstraint(fields=("tenant", "slug"), name="uniq_channel_config_slug_per_tenant") ], }, ), migrations.AddConstraint( model_name="notificationtemplate", constraint=models.UniqueConstraint( fields=("tenant", "slug", "namespace"), name="uniq_template_slug_namespace_per_tenant" ), ), migrations.AddConstraint( model_name="notificationtemplate", constraint=models.UniqueConstraint( condition=models.Q(("tenant__isnull", True)), fields=("slug", "namespace"), name="uniq_global_template_slug_namespace", ), ), migrations.AddIndex( model_name="notificationdispatch", index=models.Index(fields=["tenant_id", "status"], name="notificatio_tenant__a73911_idx"), ), ]