
DROP TABLE IF EXISTS  `cb_achievement_user_log`;

CREATE TABLE IF NOT EXISTS `cb_achievement_user_log` (
  `Log_ID` int(9) NOT NULL AUTO_INCREMENT,
  `Id` bigint(20) NOT NULL,
  `IdAchievement` bigint(20) NOT NULL,
  `IdAccount` bigint(20) NOT NULL,
  `Progress` decimal(6,2) NOT NULL,
  `LastUpdated` datetime NOT NULL,
  `Checksum` varchar(32),
	PRIMARY KEY(Log_ID)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;


--
DROP TRIGGER IF EXISTS `Log_Achievement_User`;
DELIMITER //
CREATE TRIGGER `Log_Achievement_User`  AFTER UPDATE ON `cb_achievement_user`
 FOR EACH ROW
  BEGIN
	INSERT INTO `cb_achievement_user_log`(`Id`, `IdAchievement`, `IdAccount`, `Progress`, `LastUpdated`,`Checksum`) VALUES (NEW.Id,NEW.IdAchievement, NEW.IdAccount,NEW.Progress,NEW.LastUpdated,NEW.`Checksum`) ;
  END
// DELIMITER ;

DROP TRIGGER IF EXISTS `Log_Achievement_User_Insert`;
DELIMITER //
CREATE TRIGGER `Log_Achievement_User_Insert`  AFTER INSERT ON `cb_achievement_user`
 FOR EACH ROW
  BEGIN
	INSERT INTO `cb_achievement_user_log`(`Id`, `IdAchievement`, `IdAccount`, `Progress`, `LastUpdated`,`Checksum`) VALUES (NEW.Id,NEW.IdAchievement, NEW.IdAccount,NEW.Progress,NEW.LastUpdated,NEW.`Checksum`) ;
  END
// DELIMITER ;
