@hogsend/db 0.5.0 → 0.7.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,5 @@
1
+ ALTER TABLE "bucket_memberships" ADD COLUMN "dwell_state" jsonb DEFAULT '{}'::jsonb;--> statement-breakpoint
2
+ ALTER TABLE "bucket_memberships" ADD COLUMN "dwell_anchor_at" timestamp with time zone;--> statement-breakpoint
3
+ CREATE INDEX "bucket_memberships_dwell_idx" ON "bucket_memberships" USING btree ("bucket_id","status","entered_at");--> statement-breakpoint
4
+ CREATE INDEX "bucket_memberships_bucket_id_status_id_idx" ON "bucket_memberships" USING btree ("bucket_id","status","id");--> statement-breakpoint
5
+ CREATE INDEX "bucket_memberships_dwell_lastfired_idx" ON "bucket_memberships" USING btree ("bucket_id","status","last_evaluated_at");
@@ -0,0 +1,20 @@
1
+ CREATE TABLE "contact_aliases" (
2
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
+ "contact_id" uuid NOT NULL,
4
+ "alias_kind" text NOT NULL,
5
+ "alias_value" text NOT NULL,
6
+ "from_contact_id" uuid,
7
+ "reason" text NOT NULL,
8
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
9
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
10
+ );
11
+ --> statement-breakpoint
12
+ ALTER TABLE "contacts" DROP CONSTRAINT "contacts_external_id_unique";--> statement-breakpoint
13
+ ALTER TABLE "contacts" ALTER COLUMN "external_id" DROP NOT NULL;--> statement-breakpoint
14
+ ALTER TABLE "contacts" ADD COLUMN "anonymous_id" text;--> statement-breakpoint
15
+ ALTER TABLE "contact_aliases" ADD CONSTRAINT "contact_aliases_contact_id_contacts_id_fk" FOREIGN KEY ("contact_id") REFERENCES "public"."contacts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
16
+ CREATE UNIQUE INDEX "contact_aliases_kind_value_idx" ON "contact_aliases" USING btree ("alias_kind","alias_value");--> statement-breakpoint
17
+ CREATE INDEX "contact_aliases_contact_id_idx" ON "contact_aliases" USING btree ("contact_id");--> statement-breakpoint
18
+ CREATE UNIQUE INDEX "contacts_external_id_unique_idx" ON "contacts" USING btree ("external_id") WHERE external_id IS NOT NULL AND deleted_at IS NULL;--> statement-breakpoint
19
+ CREATE UNIQUE INDEX "contacts_email_unique_idx" ON "contacts" USING btree (lower(email)) WHERE email IS NOT NULL AND deleted_at IS NULL;--> statement-breakpoint
20
+ CREATE UNIQUE INDEX "contacts_anonymous_id_unique_idx" ON "contacts" USING btree ("anonymous_id") WHERE anonymous_id IS NOT NULL AND deleted_at IS NULL;
@@ -0,0 +1,2 @@
1
+ ALTER TABLE "email_sends" ADD COLUMN "idempotency_key" text;--> statement-breakpoint
2
+ CREATE UNIQUE INDEX "email_sends_idempotency_key_idx" ON "email_sends" USING btree ("idempotency_key");
@@ -0,0 +1,23 @@
1
+ CREATE TABLE "campaigns" (
2
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3
+ "organization_id" text,
4
+ "name" text NOT NULL,
5
+ "status" text DEFAULT 'queued' NOT NULL,
6
+ "audience_kind" text NOT NULL,
7
+ "audience_id" text NOT NULL,
8
+ "template_key" text NOT NULL,
9
+ "props" jsonb DEFAULT '{}'::jsonb,
10
+ "from_email" text,
11
+ "subject" text,
12
+ "total_recipients" integer DEFAULT 0 NOT NULL,
13
+ "sent_count" integer DEFAULT 0 NOT NULL,
14
+ "skipped_count" integer DEFAULT 0 NOT NULL,
15
+ "failed_count" integer DEFAULT 0 NOT NULL,
16
+ "started_at" timestamp with time zone,
17
+ "completed_at" timestamp with time zone,
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 INDEX "campaigns_status_idx" ON "campaigns" USING btree ("status");--> statement-breakpoint
23
+ CREATE INDEX "campaigns_created_at_idx" ON "campaigns" USING btree ("created_at");
@@ -0,0 +1,2 @@
1
+ ALTER TABLE "campaigns" ADD COLUMN "idempotency_key" text;--> statement-breakpoint
2
+ CREATE UNIQUE INDEX "campaigns_idempotency_key_idx" ON "campaigns" USING btree ("idempotency_key") WHERE idempotency_key IS NOT NULL;