@hogsend/db 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ CREATE TYPE "public"."webhook_delivery_status" AS ENUM('pending', 'sending', 'delivered', 'failed', 'discarded');--> statement-breakpoint
2
+ CREATE TABLE "webhook_deliveries" (
3
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
4
+ "endpoint_id" uuid NOT NULL,
5
+ "organization_id" text,
6
+ "webhook_id" text NOT NULL,
7
+ "event_type" text NOT NULL,
8
+ "dedupe_key" text,
9
+ "payload" jsonb NOT NULL,
10
+ "status" "webhook_delivery_status" DEFAULT 'pending' NOT NULL,
11
+ "attempt_count" integer DEFAULT 0 NOT NULL,
12
+ "next_retry_at" timestamp with time zone,
13
+ "last_attempt_at" timestamp with time zone,
14
+ "response_status" integer,
15
+ "response_body_snippet" text,
16
+ "delivered_at" timestamp with time zone,
17
+ "last_error" text,
18
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
19
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
20
+ );
21
+ --> statement-breakpoint
22
+ CREATE TABLE "webhook_endpoints" (
23
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
24
+ "organization_id" text,
25
+ "url" text NOT NULL,
26
+ "description" text,
27
+ "secret" text NOT NULL,
28
+ "secret_prefix" text NOT NULL,
29
+ "event_types" jsonb DEFAULT '[]'::jsonb NOT NULL,
30
+ "disabled" boolean DEFAULT false NOT NULL,
31
+ "last_delivery_at" timestamp with time zone,
32
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
33
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
34
+ );
35
+ --> statement-breakpoint
36
+ ALTER TABLE "webhook_deliveries" ADD CONSTRAINT "webhook_deliveries_endpoint_id_webhook_endpoints_id_fk" FOREIGN KEY ("endpoint_id") REFERENCES "public"."webhook_endpoints"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
37
+ CREATE INDEX "webhook_deliveries_endpoint_idx" ON "webhook_deliveries" USING btree ("endpoint_id");--> statement-breakpoint
38
+ CREATE INDEX "webhook_deliveries_status_next_retry_idx" ON "webhook_deliveries" USING btree ("status","next_retry_at");--> statement-breakpoint
39
+ CREATE UNIQUE INDEX "webhook_deliveries_endpoint_dedupe_idx" ON "webhook_deliveries" USING btree ("endpoint_id","dedupe_key");--> statement-breakpoint
40
+ CREATE INDEX "webhook_endpoints_org_idx" ON "webhook_endpoints" USING btree ("organization_id");--> statement-breakpoint
41
+ CREATE INDEX "webhook_endpoints_disabled_idx" ON "webhook_endpoints" USING btree ("disabled");