CREATE TABLE "ur_ingest_session_imap_acct_folder_message" (
"ur_ingest_session_imap_acct_folder_message_id" VARCHAR PRIMARY KEY NOT NULL,
"ingest_session_id" VARCHAR NOT NULL,
"ingest_imap_acct_folder_id" VARCHAR NOT NULL,
"message" TEXT NOT NULL,
"message_id" TEXT NOT NULL,
"subject" TEXT NOT NULL,
"from" TEXT NOT NULL,
"cc" TEXT CHECK(json_valid(cc)) NOT NULL,
"bcc" TEXT CHECK(json_valid(bcc)) NOT NULL,
"status" TEXT[] NOT NULL,
"date" DATE,
"email_references" TEXT CHECK(json_valid(email_references)) NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
"created_by" TEXT DEFAULT 'UNKNOWN',
"updated_at" TIMESTAMPTZ,
"updated_by" TEXT,
"deleted_at" TIMESTAMPTZ,
"deleted_by" TEXT,
"activity_log" TEXT,
FOREIGN KEY("ingest_session_id") REFERENCES "ur_ingest_session"("ur_ingest_session_id"),
FOREIGN KEY("ingest_imap_acct_folder_id") REFERENCES "ur_ingest_session_imap_acct_folder"("ur_ingest_session_imap_acct_folder_id"),
UNIQUE("message", "message_id")
)