@hogsend/db 0.6.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.
- package/drizzle/0014_front_door_identity.sql +20 -0
- package/drizzle/0015_crazy_kronos.sql +2 -0
- package/drizzle/0016_campaigns.sql +23 -0
- package/drizzle/0017_long_spacker_dave.sql +2 -0
- package/drizzle/meta/0014_snapshot.json +3080 -0
- package/drizzle/meta/0015_snapshot.json +3101 -0
- package/drizzle/meta/0016_snapshot.json +3262 -0
- package/drizzle/meta/0017_snapshot.json +3284 -0
- package/drizzle/meta/_journal.json +28 -0
- package/package.json +1 -1
- package/src/schema/campaigns.ts +71 -0
- package/src/schema/contact-aliases.ts +41 -0
- package/src/schema/contacts.ts +37 -2
- package/src/schema/email-sends.ts +16 -1
- package/src/schema/index.ts +2 -0
- package/src/schema/relations.ts +15 -0
|
@@ -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,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");
|