
CREATE TABLE `was_hub_business_training_progress` (
  `business_training_progress_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(11) unsigned NOT NULL,
  `resource_id` 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 (`business_training_progress_id`),
  UNIQUE KEY `unq_business_id` (`business_id`)
) ENGINE=InnoDB COMMENT='stores hubs training progress';

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


CREATE TABLE `was_hub_business_training_video_progress` (
  `business_training_video_progress_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(11) unsigned NOT NULL,
  `resource_id` int(11) unsigned NOT NULL,
  `position` smallint(11) unsigned NOT NULL COMMENT 'current time of the video in seconds',
  `duration` smallint(11) unsigned NOT NULL COMMENT 'duration of the video in seconds',
  `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 (`business_training_video_progress_id`),
  UNIQUE KEY `unq_business_resource` (`business_id`,`resource_id`)
) ENGINE=InnoDB COMMENT='stores hubs training video progress';

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