

ALTER TABLE `was_hub_milestone_action`
  ADD `action_item_type` ENUM('BLOG', 'VLOG', 'CLASS') NULL DEFAULT NULL AFTER `action_uri`, 
  ADD `action_item_id` INT(11) UNSIGNED NULL DEFAULT NULL AFTER `action_item_type`;


CREATE TABLE `was_hub_milestone_group` (
  `milestone_group_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `business_type_id` int(11) unsigned NOT NULL,
  `group_order` int(11) unsigned NOT NULL,
  `group_title` varchar(64) NOT NULL,
  `insert_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `update_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`milestone_group_id`),
  KEY `idx_business_type_id` (`business_type_id`,`group_order`)
) ENGINE=InnoDB COMMENT='stores milestone groups for grouping tasks';

CREATE TRIGGER `was_hub_milestone_group_insert_timestamp` BEFORE INSERT ON `was_hub_milestone_group`
FOR EACH ROW SET NEW.insert_timestamp = NOW();


-- New group relationship column/index
ALTER TABLE was_hub_milestone
  ADD COLUMN `milestone_group_id` int(11) unsigned NOT NULL AFTER `milestone_id`,
  ADD KEY `idx_milestone_group_id` (`milestone_group_id`);

-- own-niche
INSERT INTO `was_hub_milestone_group` (`business_type_id`, `group_order`, `group_title`)
VALUES
(1, 1, 'Phase 1 - Getting Started'),
(1, 2, 'Phase 2 - Your Brand & Content'),
(1, 3, 'Phase 3 - Growth & Momentum'),
(1, 4, 'Phase 4 - Making Money & Scaling');

-- own-niche :: Phase 1 - Getting Started
UPDATE was_hub_milestone
SET milestone_group_id = 1
WHERE business_type_id = 1
AND slug IN('choose_niche', 'create_brand', 'build_website', 'training_intro', 'make_money_process', 'about_me',  'upgrade_membership');

-- own-niche :: Phase 2 - Your Brand & Content
UPDATE was_hub_milestone
SET milestone_group_id = 2
WHERE business_type_id = 1
AND slug IN('register_domain', 'add_logo', 'privacy_policy', 'setup_wa_profile', 'join_live_chat', 'research_and_add_writing_task', 'first_niche_article', 'create_image_using_ai', 'create_top_menu', '7x_posts', 'first_website_comment', 'create_domain_specific_email_address', 'create_gravatar', 'create_new_website_user', 'add_featured_images_to_all_posts');

-- own-niche :: Phase 3 - Growth & Momentum
UPDATE was_hub_milestone
SET milestone_group_id = 3
WHERE business_type_id = 1
AND slug IN('setup_seo_framework', 'setup_google_site_kit', 'website_speed', 'learn_ai', 'internal_linking', 'first_review_page', 'request_indexing', 'add_youtube_video_to_your_website', '15x_posts', 'join_application_based_program');

-- own-niche :: Phase 4 - Making Money & Scaling
UPDATE was_hub_milestone
SET milestone_group_id = 4
WHERE business_type_id = 1
AND slug IN('join_your_first_affiliate_program', 'add_affiliate_disclosure_page', 'affiliate_links', 'social_media_intro', 'join_facebook', 'create_facebook_page', 'first_facebook_page_post', 'join_x_com', 'first_x_com_post', 'join_pinterest', 'first_pinterest_post', 'share_on_social_media', 'explore_appearance_themes_of_your_website', 'calculate_affiliate_goals', 'apply_for_google_adsense', 'watch_scaling_business', 'watch_learn_more_with_wa', '25x_posts', 'create_new_categories_in_hubs', '50x_posts');



-- wealthyaffiliate
INSERT INTO `was_hub_milestone_group` (`business_type_id`, `group_order`, `group_title`)
VALUES
(2, 1, 'Phase 1 - Getting Started'),
(2, 2, 'Phase 2 - Your Brand & Content'),
(2, 3, 'Phase 3 - Growth & Momentum'),
(2, 4, 'Phase 4 - Promoting WA & Scaling');



-- wealthyaffiliate :: Phase 1 - Getting Started
UPDATE was_hub_milestone
SET milestone_group_id = 5
WHERE business_type_id = 2
AND slug IN('choose_to_promote_wa', 'create_brand', 'build_website', 'training_intro', 'make_money_process', 'about_me', 'upgrade_membership');

-- wealthyaffiliate :: Phase 2 - Your Brand & Content
UPDATE was_hub_milestone
SET milestone_group_id = 6
WHERE business_type_id = 2
AND slug IN('register_domain', 'add_logo', 'privacy_policy', 'affiliate_program_walkthrough', 'setup_wa_profile', 'join_live_chat', 'research_and_add_writing_task', 'publish_wa_review', 'create_top_menu', '7x_posts', 'first_website_comment', 'create_domain_specific_email_address', 'create_gravatar', 'create_new_website_user', 'add_featured_images_to_all_posts');


-- wealthyaffiliate :: Phase 3 - Growth & Momentum
UPDATE was_hub_milestone
SET milestone_group_id = 7
WHERE business_type_id = 2
AND slug IN('first_niche_article', 'create_image_using_ai', 'setup_seo_framework', 'setup_google_site_kit', 'website_speed', 'learn_ai', 'internal_linking', 'request_indexing', 'add_youtube_video_to_your_website', '15x_posts', 'join_application_based_program');


-- wealthyaffiliate :: Phase 4 - Promoting WA & Scaling
UPDATE was_hub_milestone
SET milestone_group_id = 8
WHERE business_type_id = 2
AND slug IN('join_your_first_affiliate_program', 'add_affiliate_disclosure_page', 'social_media_intro', 'join_facebook', 'create_facebook_page', 'first_facebook_page_post', 'join_x_com', 'first_x_com_post', 'join_pinterest', 'first_pinterest_post', 'share_on_social_media', 'explore_appearance_themes_of_your_website', 'calculate_affiliate_goals', 'apply_for_google_adsense', 'watch_scaling_business', 'watch_learn_more_with_wa', '25x_posts', 'create_new_categories_in_hubs', '50x_posts');



ALTER TABLE `was_hub_milestone_action`
  ADD `action_item_description` TEXT DEFAULT NULL AFTER `action_item_id`;






-- After release we can drop these deprecated columns
-- we cannot drop before release as production depends on these
ALTER TABLE was_hub_milestone 
DROP COLUMN `business_type_id`,
DROP KEY `idx_business_type_id`;
