-- ======================
-- CLUBS: Group
-- ======================
CREATE TABLE "unified_clubs_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,
  "description"            VARCHAR,
  "sport_type"             VARCHAR,
  "group_type"             VARCHAR,
  "address"                VARIANT,
  "member_count"           FLOAT,
  "following_count"        FLOAT,
  "post_count"             FLOAT,
  "is_private"             BOOLEAN,
  "is_verified"            BOOLEAN,
  "is_featured"            BOOLEAN,
  "is_admin"               BOOLEAN,
  "is_owner"               BOOLEAN,
  "membership_status"      VARCHAR,
  "url"                    VARCHAR,
  "profile_image_url"      VARCHAR,
  "cover_image_url"        VARCHAR,
  "activity_types"         VARIANT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- CLUBS: Member
-- ======================
CREATE TABLE "unified_clubs_member" (
  "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,
  "group_id"               VARCHAR,
  "is_admin"               BOOLEAN,
  "is_owner"               BOOLEAN,
  "membership_status"      VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- CLUBS: Activity
-- ======================
CREATE TABLE "unified_clubs_activity" (
  "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,
  "group_id"               VARCHAR,
  "name"                   VARCHAR,
  "description"            VARCHAR,
  "type"                   VARCHAR,
  "athlete_id"             VARCHAR,
  "athlete_name"           VARCHAR,
  "distance"               FLOAT,
  "moving_time"            FLOAT,
  "elapsed_time"           FLOAT,
  "total_elevation_gain"   FLOAT,
  "elevation_high"         FLOAT,
  "elevation_low"          FLOAT,
  "start_at"               TIMESTAMP_NTZ,
  "timezone"               VARCHAR,
  "achievement_count"      FLOAT,
  "kudos_count"            FLOAT,
  "comment_count"          FLOAT,
  "athlete_count"          FLOAT,
  "photo_count"            FLOAT,
  "average_speed"          FLOAT,
  "max_speed"              FLOAT,
  "average_cadence"        FLOAT,
  "average_heartrate"      FLOAT,
  "max_heartrate"          FLOAT,
  "average_watts"          FLOAT,
  "max_watts"              FLOAT,
  "weighted_average_watts" FLOAT,
  "kilojoules"             FLOAT,
  "calories"               FLOAT,
  "has_heartrate"          BOOLEAN,
  "is_trainer"             BOOLEAN,
  "is_commute"             BOOLEAN,
  "is_manual"              BOOLEAN,
  "is_private"             BOOLEAN,
  "map_polyline"           VARCHAR,
  "map_summary_polyline"   VARCHAR,
  "workout_type"           FLOAT,
  "suffer_score"           FLOAT,
  "pr_count"               FLOAT,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- CLUBS: Event
-- ======================
CREATE TABLE "unified_clubs_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,
  "updated_at"             TIMESTAMP_NTZ,
  "group_id"               VARCHAR,
  "name"                   VARCHAR,
  "description"            VARCHAR,
  "type"                   VARCHAR,
  "status"                 VARCHAR,
  "start_at"               TIMESTAMP_NTZ,
  "end_at"                 TIMESTAMP_NTZ,
  "timezone"               VARCHAR,
  "duration_minutes"       FLOAT,
  "location_id"            VARCHAR,
  "location_name"          VARCHAR,
  "opponent_id"            VARCHAR,
  "opponent_name"          VARCHAR,
  "home_team_name"         VARCHAR,
  "away_team_name"         VARCHAR,
  "home_score"             FLOAT,
  "away_score"             FLOAT,
  "score_for"              FLOAT,
  "score_against"          FLOAT,
  "is_home"                BOOLEAN,
  "url"                    VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
-- ======================
-- CLUBS: Location
-- ======================
CREATE TABLE "unified_clubs_location" (
  "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,
  "group_id"               VARCHAR,
  "name"                   VARCHAR,
  "address"                VARIANT,
  "latitude"               FLOAT,
  "longitude"              FLOAT,
  "telephone"              VARCHAR,
  "url"                    VARCHAR,
  "raw"                    VARIANT,
  UNIQUE ("unified_connection_id", "unified_id")
);
