# Generated by Django 5.2.17 on 2026-09-24 14:10 import django.db.models.deletion from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ("tenancy", "0001_initial"), ] operations = [ migrations.CreateModel( name="InboundEndpoint", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("name", models.CharField(max_length=255)), ("slug", models.SlugField()), ( "source", models.CharField( choices=[ ("stripe", "Stripe"), ("github", "GitHub"), ("mercadopago", "Mercado Pago"), ("custom", "Custom"), ], max_length=50, ), ), ("secret", models.CharField(max_length=500)), ("handler", models.CharField(max_length=500)), ("is_active", models.BooleanField(default=True)), ("created_at", models.DateTimeField(auto_now_add=True)), ("updated_at", models.DateTimeField(auto_now=True)), ( "tenant", models.ForeignKey( editable=False, on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tenancy.tenant", ), ), ], options={ "db_table": "webhooks_inbound_endpoint", }, ), migrations.CreateModel( name="InboundEvent", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("event_type", models.CharField(max_length=255)), ("raw_payload", models.JSONField()), ("is_verified", models.BooleanField(default=False)), ("is_processed", models.BooleanField(default=False)), ("error", models.TextField(blank=True)), ("received_at", models.DateTimeField(auto_now_add=True)), ("processed_at", models.DateTimeField(blank=True, null=True)), ( "endpoint", models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, related_name="events", to="infrasynth_webhooks.inboundendpoint", ), ), ( "tenant", models.ForeignKey( editable=False, on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tenancy.tenant", ), ), ], options={ "db_table": "webhooks_inbound_event", }, ), migrations.CreateModel( name="OutboundEndpoint", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("name", models.CharField(max_length=255)), ("url", models.URLField(max_length=1000)), ("secret", models.CharField(max_length=500)), ("is_active", models.BooleanField(default=True)), ("retry_policy", models.JSONField(blank=True, default=dict)), ("headers", models.JSONField(blank=True, default=dict)), ("timeout_seconds", models.PositiveIntegerField(default=30)), ("created_at", models.DateTimeField(auto_now_add=True)), ("updated_at", models.DateTimeField(auto_now=True)), ( "tenant", models.ForeignKey( editable=False, on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tenancy.tenant", ), ), ], options={ "db_table": "webhooks_outbound_endpoint", }, ), migrations.CreateModel( name="OutboundSubscription", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("event_name", models.CharField(db_index=True, max_length=255)), ("is_active", models.BooleanField(default=True)), ("payload_template", models.TextField(blank=True)), ("created_at", models.DateTimeField(auto_now_add=True)), ("updated_at", models.DateTimeField(auto_now=True)), ( "endpoint", models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, related_name="subscriptions", to="infrasynth_webhooks.outboundendpoint", ), ), ( "tenant", models.ForeignKey( editable=False, on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tenancy.tenant", ), ), ], options={ "db_table": "webhooks_outbound_subscription", }, ), migrations.CreateModel( name="OutboundDelivery", fields=[ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("payload", models.JSONField()), ("response_status", models.PositiveSmallIntegerField(blank=True, null=True)), ("response_body", models.TextField(blank=True)), ("attempt", models.PositiveIntegerField(default=0)), ( "status", models.CharField( choices=[("success", "Success"), ("failed", "Failed"), ("retrying", "Retrying")], default="retrying", max_length=20, ), ), ("next_retry_at", models.DateTimeField(blank=True, null=True)), ("created_at", models.DateTimeField(auto_now_add=True)), ("completed_at", models.DateTimeField(blank=True, null=True)), ( "tenant", models.ForeignKey( editable=False, on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tenancy.tenant", ), ), ( "subscription", models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, related_name="deliveries", to="infrasynth_webhooks.outboundsubscription", ), ), ], options={ "db_table": "webhooks_outbound_delivery", }, ), migrations.AddConstraint( model_name="inboundendpoint", constraint=models.UniqueConstraint(fields=("tenant", "slug"), name="uniq_inbound_endpoint_slug_per_tenant"), ), migrations.AddIndex( model_name="inboundevent", index=models.Index(fields=["tenant_id", "is_processed"], name="webhooks_in_tenant__9d147e_idx"), ), migrations.AddIndex( model_name="outboundendpoint", index=models.Index(fields=["tenant_id", "is_active"], name="webhooks_ou_tenant__2c9365_idx"), ), migrations.AddConstraint( model_name="outboundsubscription", constraint=models.UniqueConstraint( fields=("endpoint", "event_name"), name="uniq_subscription_event_per_endpoint" ), ), migrations.AddIndex( model_name="outbounddelivery", index=models.Index(fields=["tenant_id", "status"], name="webhooks_ou_tenant__7f1857_idx"), ), ]