task-ep.1.5

This commit is contained in:
phaichayon
2026-07-13 15:03:17 +07:00
parent bba4c8d97d
commit 2bc8dd184c
19 changed files with 9722 additions and 5 deletions

View File

@@ -0,0 +1,33 @@
CREATE TABLE "crm_timeline_projection" (
"id" text PRIMARY KEY NOT NULL,
"organization_id" text NOT NULL,
"branch_id" text,
"customer_id" text,
"lead_id" text,
"opportunity_id" text,
"quotation_id" text,
"activity_id" text,
"event_id" text NOT NULL,
"entity_type" text NOT NULL,
"entity_id" text NOT NULL,
"timeline_type" text NOT NULL,
"timeline_category" text NOT NULL,
"occurred_at" timestamp with time zone NOT NULL,
"actor_id" text,
"actor_display" text,
"title" text NOT NULL,
"summary" text,
"icon" text NOT NULL,
"color" text NOT NULL,
"priority" text DEFAULT 'normal' NOT NULL,
"visibility" jsonb NOT NULL,
"metadata" jsonb,
"source_event" jsonb NOT NULL,
"source_projection_version" integer DEFAULT 1 NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX "crm_timeline_projection_event_version_idx" ON "crm_timeline_projection" USING btree ("event_id","source_projection_version");--> statement-breakpoint
CREATE INDEX "crm_timeline_projection_org_occurred_idx" ON "crm_timeline_projection" USING btree ("organization_id","occurred_at");--> statement-breakpoint
CREATE INDEX "crm_timeline_projection_customer_occurred_idx" ON "crm_timeline_projection" USING btree ("organization_id","customer_id","occurred_at");--> statement-breakpoint
CREATE INDEX "crm_timeline_projection_activity_event_idx" ON "crm_timeline_projection" USING btree ("activity_id","event_id");