
CREATE TABLE `was_hub_business` (
  `business_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) unsigned NOT NULL,
  `business_domain` varchar(265) NOT NULL,
  `business_niche` varchar(100) NOT NULL,
  `business_brand` varchar(100) NOT NULL,
  `page_count` int(11) unsigned DEFAULT NULL,
  `post_count` int(11) unsigned DEFAULT NULL,
  `comment_count` int(11) unsigned DEFAULT NULL,
  `update_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `insert_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`business_id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_business_domain` (`business_domain`)
) ENGINE=InnoDB COMMENT='stores business hubs of users';

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


CREATE TABLE `was_hub_idea_category` (
  `category_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(11) unsigned NOT NULL,
  `category_name` varchar(100) NOT NULL,
  `published` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `update_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `insert_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`category_id`),
  KEY `idx_business_id` (`business_id`)
) ENGINE=InnoDB COMMENT='stores categories for business hub ideas';

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


CREATE TABLE `was_hub_idea_article` (
  `article_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `category_id` int(11) unsigned NOT NULL,
  `article_title` varchar(100) NOT NULL,
  `status` ENUM('PENDING', 'TASKED', 'DELETED') NOT NULL DEFAULT 'PENDING',
  `update_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `insert_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`article_id`),
  KEY `idx_category_id` (`category_id`)
) ENGINE=InnoDB COMMENT='stores articles for business hubs';

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


CREATE TABLE `was_hub_task` (
  `task_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(11) unsigned NOT NULL,
  `task_title` varchar(200) NOT NULL,
  `task_type` ENUM('AI_DESIGN','SITECONTENT','PRIVACY_POLICY','AFFILIATE_DISCLOSURE') DEFAULT NULL,
  `task_order` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `origin_id` int(11) unsigned DEFAULT NULL,
  `job_id` int(11) unsigned DEFAULT NULL,
  `update_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `insert_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`task_id`),
  KEY `idx_business_id` (`business_id`)
) ENGINE=InnoDB COMMENT='stores tasks for users for each hub';

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