-- ======================
-- CDP: Profile
-- ======================
CREATE TABLE "unified_cdp_profile" (
  "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,
  "email"                  VARCHAR,
  "telephone"              VARCHAR,
  "gender"                 VARCHAR,
  "birthdate"              VARCHAR,
  "title"                  VARCHAR,
  "company"                VARCHAR,
  "address"                VARIANT,
  "identifiers"            VARIANT,
  "metadata"               VARIANT,
  "segments"               VARIANT,
  "is_anonymous"           BOOLEAN,
  "consent"                VARIANT,
  "source_id"              VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- CDP: Segment
-- ======================
CREATE TABLE "unified_cdp_segment" (
  "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,
  "slug"                   VARCHAR,
  "description"            VARCHAR,
  "definition"             VARCHAR,
  "type"                   VARCHAR,
  "compute_mode"           VARCHAR,
  "size"                   FLOAT,
  "is_active"              BOOLEAN,
  "source_id"              VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- CDP: Event
-- ======================
CREATE TABLE "unified_cdp_event" (
  "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,
  "name"                   VARCHAR,
  "type"                   VARCHAR,
  "occurred_at"            TIMESTAMP_NTZ,
  "profile_id"             VARCHAR,
  "identifiers"            VARIANT,
  "metadata"               VARIANT,
  "source"                 VARCHAR,
  "source_id"              VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- CDP: Source
-- ======================
CREATE TABLE "unified_cdp_source" (
  "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,
  "slug"                   VARCHAR,
  "type"                   VARCHAR,
  "direction"              VARCHAR,
  "is_enabled"             BOOLEAN,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- CDP: Destination
-- ======================
CREATE TABLE "unified_cdp_destination" (
  "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,
  "slug"                   VARCHAR,
  "type"                   VARCHAR,
  "direction"              VARCHAR,
  "is_enabled"             BOOLEAN,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- CDP: Activation
-- ======================
CREATE TABLE "unified_cdp_activation" (
  "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,
  "segment_id"             VARCHAR,
  "destination_id"         VARCHAR,
  "source_id"              VARCHAR,
  "schedule"               VARCHAR,
  "status"                 VARCHAR,
  "last_run_at"            TIMESTAMP_NTZ,
  "is_enabled"             BOOLEAN,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
