-- ======================
-- ADS: Organization
-- ======================
CREATE TABLE "unified_ads_organization" (
  "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,
  "currency"               VARCHAR,
  "timezone"               VARCHAR,
  "parent_id"              VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- ADS: Campaign
-- ======================
CREATE TABLE "unified_ads_campaign" (
  "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,
  "organization_id"        VARCHAR,
  "status"                 VARCHAR,
  "effective_status"       VARCHAR,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "budget_amount"          FLOAT,
  "budget_period"          VARCHAR,
  "total_spend_amount"     FLOAT,
  "targeting"              VARIANT,
  "goal"                   VARCHAR,
  "planned_spend_amount"   FLOAT,
  "frequency_cap"          VARIANT,
  "advertising_channel_type" VARCHAR,
  "campaign_budget_identifier" VARCHAR,
  "currency"               VARCHAR,
  "category"               VARCHAR,
  "has_eu_political_ads"   BOOLEAN,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- ADS: Creative
-- ======================
CREATE TABLE "unified_ads_creative" (
  "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,
  "campaign_id"            VARCHAR,
  "group_id"               VARCHAR,
  "item_id"                VARCHAR,
  "organization_id"        VARCHAR,
  "status"                 VARCHAR,
  "creative_type"          VARCHAR,
  "hosting_source"         VARCHAR,
  "width"                  FLOAT,
  "height"                 FLOAT,
  "asset_urls"             VARIANT,
  "link_url"               VARCHAR,
  "body"                   VARCHAR,
  "title"                  VARCHAR,
  "cta"                    VARCHAR,
  "third_party_tag"        VARCHAR,
  "vast_tag_url"           VARCHAR,
  "external_creative_reference" VARCHAR,
  "external_placement_reference" VARCHAR,
  "external_ad_reference"  VARCHAR,
  "promoted"               VARIANT,
  "path1"                  VARCHAR,
  "path2"                  VARCHAR,
  "data"                   VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- ADS: Insertionorder
-- ======================
CREATE TABLE "unified_ads_insertionorder" (
  "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,
  "organization_id"        VARCHAR,
  "campaign_id"            VARCHAR,
  "status"                 VARCHAR,
  "pacing"                 VARIANT,
  "frequency_cap"          VARIANT,
  "kpi"                    VARIANT,
  "budget_unit"            VARCHAR,
  "budget_segments"        VARIANT,
  "bid_strategy"           VARIANT,
  "reference"              VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- ADS: Group
-- ======================
CREATE TABLE "unified_ads_group" (
  "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,
  "parent_id"              VARCHAR,
  "campaign_id"            VARCHAR,
  "organization_id"        VARCHAR,
  "insertionorder_id"      VARCHAR,
  "status"                 VARCHAR,
  "effective_status"       VARCHAR,
  "targeting"              VARIANT,
  "bid_amount"             FLOAT,
  "bid_strategy"           VARIANT,
  "budget_amount"          FLOAT,
  "budget_period"          VARCHAR,
  "budget_allocation_type" VARCHAR,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "budget_unit"            VARCHAR,
  "budget_max_amount"      FLOAT,
  "type"                   VARCHAR,
  "has_eu_political_ads"   BOOLEAN,
  "pacing"                 VARIANT,
  "frequency_cap"          VARIANT,
  "creative_ids"           VARIANT,
  "optimization_goal"      VARCHAR,
  "billing_event"          VARCHAR,
  "currency"               VARCHAR,
  "promoted"               VARIANT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- ADS: Ad
-- ======================
CREATE TABLE "unified_ads_ad" (
  "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,
  "campaign_id"            VARCHAR,
  "group_id"               VARCHAR,
  "organization_id"        VARCHAR,
  "status"                 VARCHAR,
  "ad_type"                VARCHAR,
  "advertiser_name"        VARCHAR,
  "creative_ids"           VARIANT,
  "creative_asset_url"     VARCHAR,
  "ad_copy"                VARCHAR,
  "headline"               VARCHAR,
  "description"            VARCHAR,
  "cta"                    VARCHAR,
  "final_url"              VARCHAR,
  "display_url"            VARCHAR,
  "path1"                  VARCHAR,
  "path2"                  VARCHAR,
  "promoted"               VARIANT,
  "logo_creative_id"       VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- ADS: Report
-- ======================
CREATE TABLE "unified_ads_report" (
  "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,
  "currency"               VARCHAR,
  "metrics"                VARIANT,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "organization_id"        VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- ADS: Target
-- ======================
CREATE TABLE "unified_ads_target" (
  "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,
  "name"                   VARCHAR,
  "type"                   VARCHAR,
  "is_active"              BOOLEAN,
  "parent_id"              VARCHAR,
  "audience_count_min"     FLOAT,
  "audience_count_max"     FLOAT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- ADS: Promoted
-- ======================
CREATE TABLE "unified_ads_promoted" (
  "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,
  "name"                   VARCHAR,
  "type"                   VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
