
CREATE TABLE `was_openai_niche_search` (
  `openai_niche_search_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `openai_request_id` int(11) DEFAULT NULL,
  `search_input` varchar(50) NOT NULL,
  `expire_date` int(11) unsigned 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 (`openai_niche_search_id`),
  KEY `idx_openai_request_id` (`openai_request_id`),
  KEY `idx_search_input` (`search_input`)
) ENGINE=InnoDB COMMENT='stores website niche search input data';

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

CREATE TABLE `was_openai_niche_search_result` (
  `openai_niche_search_result_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `openai_niche_search_id` int(11) DEFAULT NULL,
  `search_result` varchar(100) NOT NULL,
  `profit_scale` tinyint unsigned NOT NULL,
  `search_desc` TEXT 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 (`openai_niche_search_result_id`),
  KEY `idx_openai_niche_search_id` (`openai_niche_search_id`)
) ENGINE=InnoDB COMMENT='stores website niche search result data';

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