-- ======================
-- CLUBS: Group
-- ======================
CREATE TABLE unified_clubs_group (
  unified_connection_id  text NOT NULL,
  unified_webhook_id     text NOT NULL,
  unified_external_xref  text,
  unified_integration_type text NOT NULL,
  unified_raw_id         text,
  unified_id             text NOT NULL,
  id                   text,
  created_at           timestamptz,
  updated_at           timestamptz,
  name                 text,
  description          text,
  sport_type           text,
  group_type           text,
  address              jsonb,
  member_count         numeric,
  following_count      numeric,
  post_count           numeric,
  is_private           boolean,
  is_verified          boolean,
  is_featured          boolean,
  is_admin             boolean,
  is_owner             boolean,
  membership_status    text,
  url                  text,
  profile_image_url    text,
  cover_image_url      text,
  activity_types       text[],
  raw                  jsonb
);
-- ======================
-- CLUBS: Member
-- ======================
CREATE TABLE unified_clubs_member (
  unified_connection_id  text NOT NULL,
  unified_webhook_id     text NOT NULL,
  unified_external_xref  text,
  unified_integration_type text NOT NULL,
  unified_raw_id         text,
  unified_id             text NOT NULL,
  id                   text,
  created_at           timestamptz,
  updated_at           timestamptz,
  name                 text,
  first_name           text,
  last_name            text,
  group_id             text,
  is_admin             boolean,
  is_owner             boolean,
  membership_status    text,
  raw                  jsonb
);
-- ======================
-- CLUBS: Activity
-- ======================
CREATE TABLE unified_clubs_activity (
  unified_connection_id  text NOT NULL,
  unified_webhook_id     text NOT NULL,
  unified_external_xref  text,
  unified_integration_type text NOT NULL,
  unified_raw_id         text,
  unified_id             text NOT NULL,
  id                   text,
  created_at           timestamptz,
  updated_at           timestamptz,
  group_id             text,
  name                 text,
  description          text,
  type                 text,
  athlete_id           text,
  athlete_name         text,
  distance             numeric,
  moving_time          numeric,
  elapsed_time         numeric,
  total_elevation_gain numeric,
  elevation_high       numeric,
  elevation_low        numeric,
  start_at             timestamptz,
  timezone             text,
  achievement_count    numeric,
  kudos_count          numeric,
  comment_count        numeric,
  athlete_count        numeric,
  photo_count          numeric,
  average_speed        numeric,
  max_speed            numeric,
  average_cadence      numeric,
  average_heartrate    numeric,
  max_heartrate        numeric,
  average_watts        numeric,
  max_watts            numeric,
  weighted_average_watts numeric,
  kilojoules           numeric,
  calories             numeric,
  has_heartrate        boolean,
  is_trainer           boolean,
  is_commute           boolean,
  is_manual            boolean,
  is_private           boolean,
  map_polyline         text,
  map_summary_polyline text,
  workout_type         numeric,
  suffer_score         numeric,
  pr_count             numeric,
  raw                  jsonb
);
-- ======================
-- CLUBS: Event
-- ======================
CREATE TABLE unified_clubs_event (
  unified_connection_id  text NOT NULL,
  unified_webhook_id     text NOT NULL,
  unified_external_xref  text,
  unified_integration_type text NOT NULL,
  unified_raw_id         text,
  unified_id             text NOT NULL,
  id                   text,
  created_at           timestamptz,
  updated_at           timestamptz,
  group_id             text,
  name                 text,
  description          text,
  type                 text,
  status               text,
  start_at             timestamptz,
  end_at               timestamptz,
  timezone             text,
  duration_minutes     numeric,
  location_id          text,
  location_name        text,
  opponent_id          text,
  opponent_name        text,
  home_team_name       text,
  away_team_name       text,
  home_score           numeric,
  away_score           numeric,
  score_for            numeric,
  score_against        numeric,
  is_home              boolean,
  url                  text,
  raw                  jsonb
);
-- ======================
-- CLUBS: Location
-- ======================
CREATE TABLE unified_clubs_location (
  unified_connection_id  text NOT NULL,
  unified_webhook_id     text NOT NULL,
  unified_external_xref  text,
  unified_integration_type text NOT NULL,
  unified_raw_id         text,
  unified_id             text NOT NULL,
  id                   text,
  created_at           timestamptz,
  updated_at           timestamptz,
  group_id             text,
  name                 text,
  address              jsonb,
  latitude             numeric,
  longitude            numeric,
  telephone            text,
  url                  text,
  raw                  jsonb
);
