CREATE TABLE "core_messages" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"raingull_id" char(32) NOT NULL UNIQUE,
"status" varchar(20) NOT NULL,
"service_message_id" varchar(255) NULL,
"subject" varchar(255) NULL,
"sender" varchar(255) NULL,
"timestamp" datetime NULL,
"payload" text NOT NULL CHECK ((JSON_VALID("payload") OR "payload" IS NULL)),
"standardized_payload" text NULL CHECK ((JSON_VALID("standardized_payload") OR "standardized_payload" IS NULL)),
"attachments" text NOT NULL CHECK ((JSON_VALID("attachments") OR "attachments" IS NULL)),
"is_urgent" bool NOT NULL,
"error_message" text NULL,
"created_at" datetime NOT NULL,
"updated_at" datetime NOT NULL,
"standardized_at" datetime NULL,
"user_id" varchar(8) NULL REFERENCES "core_users" ("uuid") DEFERRABLE INITIALLY DEFERRED,
"service_id" bigint NOT NULL REFERENCES "core_services" ("id") DEFERRABLE INITIALLY DEFERRED
)