
-- Update stats type of 'Like Count' to correct type i.e. 7
UPDATE was_event_stats_raw
SET stats_type = 7
WHERE stats_type = 2 AND stats_data = '';

-- Insert like records in to table 'wa_like' from table 'was_event_stats_raw'
INSERT INTO wa_like (profile_id, type, type_id, created_date, insert_timestamp)
  SELECT sp.profile_id, 'RESOURCE' AS type, event_type_id AS type_id, UNIX_TIMESTAMP(sr.insert_timestamp) AS created_date, sr.insert_timestamp
  FROM was_event_stats_raw sr
  JOIN was_event e ON e.event_id = sr.event_id
  JOIN space_profile sp ON sp.user_id = e.user_id
  WHERE sr.stats_type = 7;

-- Add new stats column 'play_count'
ALTER TABLE `was_event_stats`
  ADD `play_count` INT(11) UNSIGNED NOT NULL AFTER `like_count`;

-- Add new stats columns 'comment_count', 'like_count', 'play_count'
ALTER TABLE `was_event_stats_day`
  ADD `comment_count` INT(11) UNSIGNED NOT NULL AFTER `stats_day`,
  ADD `like_count` INT(11) UNSIGNED NOT NULL AFTER `comment_count`,
  ADD `play_count` INT(11) UNSIGNED NOT NULL AFTER `like_count`;

-- Add new stats columns 'comment_count', 'like_count', 'play_count'
ALTER TABLE `was_event_stats_hour`
  ADD `comment_count` INT(11) UNSIGNED NOT NULL AFTER `stats_hour`,
  ADD `like_count` INT(11) UNSIGNED NOT NULL AFTER `comment_count`,
  ADD `play_count` INT(11) UNSIGNED NOT NULL AFTER `like_count`;
