@hogsend/db 0.0.1 → 0.2.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,2 @@
1
+ ALTER TABLE "contacts" ADD COLUMN "timezone" text;--> statement-breakpoint
2
+ CREATE INDEX "email_sends_freq_cap_idx" ON "email_sends" USING btree ("to_email","created_at","category");
@@ -0,0 +1,8 @@
1
+ ALTER TABLE "email_sends" ADD COLUMN "user_id" text;--> statement-breakpoint
2
+ ALTER TABLE "email_sends" ADD COLUMN "user_email" text;--> statement-breakpoint
3
+ ALTER TABLE "email_sends" ADD COLUMN "bounce_type" text;--> statement-breakpoint
4
+ ALTER TABLE "email_sends" ADD COLUMN "bounce_reason" text;--> statement-breakpoint
5
+ CREATE INDEX "email_sends_user_id_idx" ON "email_sends" USING btree ("user_id");--> statement-breakpoint
6
+ -- Backfill denormalized identity for existing rows.
7
+ UPDATE "email_sends" AS es SET "user_id" = js."user_id", "user_email" = js."user_email" FROM "journey_states" js WHERE es."journey_state_id" = js."id" AND es."user_id" IS NULL;--> statement-breakpoint
8
+ UPDATE "email_sends" SET "user_email" = "to_email" WHERE "user_email" IS NULL;
@@ -0,0 +1,35 @@
1
+ CREATE TYPE "public"."bucket_membership_status" AS ENUM('active', 'left');--> statement-breakpoint
2
+ CREATE TABLE "bucket_configs" (
3
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
4
+ "bucket_id" text NOT NULL,
5
+ "enabled" boolean DEFAULT true NOT NULL,
6
+ "criteria_hash" text,
7
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
8
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE TABLE "bucket_memberships" (
12
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
13
+ "organization_id" text,
14
+ "user_id" text NOT NULL,
15
+ "user_email" text,
16
+ "bucket_id" text NOT NULL,
17
+ "status" "bucket_membership_status" DEFAULT 'active' NOT NULL,
18
+ "entered_at" timestamp with time zone DEFAULT now() NOT NULL,
19
+ "left_at" timestamp with time zone,
20
+ "expires_at" timestamp with time zone,
21
+ "last_evaluated_at" timestamp with time zone,
22
+ "entry_count" integer DEFAULT 1 NOT NULL,
23
+ "source" text,
24
+ "context" jsonb DEFAULT '{}'::jsonb,
25
+ "deleted_at" timestamp with time zone,
26
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
27
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
28
+ );
29
+ --> statement-breakpoint
30
+ CREATE UNIQUE INDEX "bucket_configs_bucket_id_idx" ON "bucket_configs" USING btree ("bucket_id");--> statement-breakpoint
31
+ CREATE UNIQUE INDEX "uq_user_bucket_active" ON "bucket_memberships" USING btree ("user_id","bucket_id") WHERE status = 'active' AND deleted_at IS NULL;--> statement-breakpoint
32
+ CREATE INDEX "bucket_memberships_bucket_id_status_idx" ON "bucket_memberships" USING btree ("bucket_id","status");--> statement-breakpoint
33
+ CREATE INDEX "bucket_memberships_user_id_idx" ON "bucket_memberships" USING btree ("user_id");--> statement-breakpoint
34
+ CREATE INDEX "bucket_memberships_last_evaluated_idx" ON "bucket_memberships" USING btree ("last_evaluated_at");--> statement-breakpoint
35
+ CREATE INDEX "bucket_memberships_expires_at_idx" ON "bucket_memberships" USING btree ("expires_at");
@@ -0,0 +1,2 @@
1
+ ALTER TABLE "bucket_memberships" ADD COLUMN "max_dwell_at" timestamp with time zone;--> statement-breakpoint
2
+ CREATE INDEX "bucket_memberships_max_dwell_at_idx" ON "bucket_memberships" USING btree ("max_dwell_at");