CREATE TABLE IF NOT EXISTS twitch_revenue
  ( date TEXT PRIMARY KEY
  , ad_break_minutes INTEGER NOT NULL
  , ad_time_seconds_per_hour REAL NOT NULL
  , average_viewers REAL NOT NULL
  , chat_messages INTEGER NOT NULL
  , chatters INTEGER NOT NULL
  , clip_views INTEGER NOT NULL
  , clips_created INTEGER NOT NULL
  , follows INTEGER NOT NULL
  , hosts_and_raids_viewers INTEGER NOT NULL
  , live_views INTEGER NOT NULL
  , max_viewers INTEGER NOT NULL
  , minutes_watched INTEGER NOT NULL
  , minutes_streamed INTEGER NOT NULL
  , unique_viewers INTEGER NOT NULL
  , sub_revenue REAL NOT NULL
  , prime_revenue REAL NOT NULL
  , gifted_subs_revenue REAL NOT NULL
  , multi_month_gifted_subs_revenue REAL NOT NULL
  , bits_revenue REAL NOT NULL
  , ad_revenue REAL NOT NULL
  , game_sales_revenue REAL NOT NULL
  , extensions_revenue REAL NOT NULL
  , bounties_revenue REAL NOT NULL
  , prime_subs INTEGER NOT NULL
  , total_paid_subs INTEGER NOT NULL
  , tier_one_subs INTEGER NOT NULL
  , total_gifted_subs INTEGER NOT NULL
  , gifted_tier_one_subs INTEGER NOT NULL
  , gifted_tier_two_subs INTEGER NOT NULL
  , gifted_tier_three_subs INTEGER NOT NULL
  , total_multi_month_gifted_subs INTEGER NOT NULL
  , multi_month_gifted_tier_one_subs INTEGER NOT NULL
  , multi_month_gifted_tier_two_subs INTEGER NOT NULL
  , multi_month_gifted_tier_three_subs INTEGER NOT NULL
  -- generated columns
  , total_revenue REAL GENERATED ALWAYS AS (sub_revenue + prime_revenue + gifted_subs_revenue + multi_month_gifted_subs_revenue + bits_revenue + ad_revenue + game_sales_revenue + extensions_revenue + bounties_revenue)
  );

CREATE TABLE IF NOT EXISTS sql_queries
  ( name   TEXT  PRIMARY KEY
  , query  TEXT  UNIQUE       NOT NULL
  , who    TEXT               NOT NULL
  );
