-- ======================
-- UC: Call
-- ======================
CREATE TABLE "unified_uc_call" (
  "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,
  "contact_id"             VARCHAR,
  "telephone"              VARIANT,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "user_id"                VARCHAR,
  "contacts"               VARIANT,
  "is_private"             BOOLEAN,
  "user_name"              VARCHAR,
  "user_phone"             VARCHAR,
  "type"                   VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- UC: Contact
-- ======================
CREATE TABLE "unified_uc_contact" (
  "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,
  "first_name"             VARCHAR,
  "last_name"              VARCHAR,
  "title"                  VARCHAR,
  "company"                VARCHAR,
  "emails"                 VARIANT,
  "telephones"             VARIANT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- UC: Comment
-- ======================
CREATE TABLE "unified_uc_comment" (
  "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"             VARCHAR,
  "updated_at"             VARCHAR,
  "content"                VARCHAR,
  "user_id"                VARCHAR,
  "call_id"                VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- UC: Recording
-- ======================
CREATE TABLE "unified_uc_recording" (
  "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,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "expires_at"             TIMESTAMP_NTZ,
  "call_id"                VARCHAR,
  "web_url"                VARCHAR,
  "contact_id"             VARCHAR,
  "contact_name"           VARCHAR,
  "contact_phone"          VARCHAR,
  "contacts"               VARIANT,
  "user_id"                VARCHAR,
  "media"                  VARIANT,
  "user_name"              VARCHAR,
  "user_phone"             VARCHAR,
  "type"                   VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
