KI-AGENT: Mailantworten und Entitätsverknüpfungen ergänzen
This commit is contained in:
27
backend/db/migrations/0066_email_entity_links.sql
Normal file
27
backend/db/migrations/0066_email_entity_links.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE IF NOT EXISTS "email_entity_links" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"tenant_id" bigint NOT NULL,
|
||||
"message_id" uuid NOT NULL,
|
||||
"entity_type" text NOT NULL,
|
||||
"entity_id" bigint NOT NULL,
|
||||
"linked_by" uuid,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "email_entity_links_tenant_id_tenants_id_fk"
|
||||
FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id")
|
||||
ON DELETE cascade ON UPDATE cascade,
|
||||
CONSTRAINT "email_entity_links_message_id_email_messages_id_fk"
|
||||
FOREIGN KEY ("message_id") REFERENCES "public"."email_messages"("id")
|
||||
ON DELETE cascade ON UPDATE cascade,
|
||||
CONSTRAINT "email_entity_links_linked_by_auth_users_id_fk"
|
||||
FOREIGN KEY ("linked_by") REFERENCES "public"."auth_users"("id")
|
||||
ON DELETE set null ON UPDATE cascade
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "email_entity_links_message_entity_key"
|
||||
ON "email_entity_links" USING btree ("message_id", "entity_type", "entity_id");
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "email_entity_links_entity_idx"
|
||||
ON "email_entity_links" USING btree ("tenant_id", "entity_type", "entity_id");
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "email_entity_links_message_idx"
|
||||
ON "email_entity_links" USING btree ("message_id");
|
||||
@@ -442,6 +442,13 @@
|
||||
"when": 1788202715001,
|
||||
"tag": "0065_document_templates",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 63,
|
||||
"version": "7",
|
||||
"when": 1788799700000,
|
||||
"tag": "0066_email_entity_links",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user