-- ======================
-- MESSAGING: Channel
-- ======================
CREATE TABLE "unified_messaging_channel" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "name"                   VARCHAR,
  "description"            VARCHAR,
  "parent_id"              VARCHAR,
  "has_subchannels"        BOOLEAN,
  "members"                VARIANT,
  "is_active"              BOOLEAN,
  "is_private"             BOOLEAN,
  "web_url"                VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- MESSAGING: Message
-- ======================
CREATE TABLE "unified_messaging_message" (
  "unified_connection_id"  VARCHAR NOT NULL,
  "unified_webhook_id"     VARCHAR NOT NULL,
  "unified_external_xref"  VARCHAR,
  "unified_integration_type" VARCHAR NOT NULL,
  "unified_raw_id"         VARCHAR,
  "unified_id"             VARCHAR NOT NULL,
  "id"                     VARCHAR,
  "created_at"             TIMESTAMP_NTZ,
  "updated_at"             TIMESTAMP_NTZ,
  "channel_id"             VARCHAR,
  "channel_ids"            VARIANT,
  "channels"               VARIANT,
  "parent_id"              VARCHAR,
  "root_message_id"        VARCHAR,
  "message_thread_identifier" VARCHAR,
  "author_member"          VARIANT,
  "destination_members"    VARIANT,
  "hidden_members"         VARIANT,
  "mentioned_members"      VARIANT,
  "reactions"              VARIANT,
  "subject"                VARCHAR,
  "message"                VARCHAR,
  "message_html"           VARCHAR,
  "message_markdown"       VARCHAR,
  "attachments"            VARIANT,
  "web_url"                VARCHAR,
  "reference"              VARCHAR,
  "has_children"           BOOLEAN,
  "is_unread"              BOOLEAN,
  "buttons"                VARIANT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
