Last active
May 8, 2018 00:41
-
-
Save MrsTonedOne/2460fcf93622a90552544f756843dbc0 to your computer and use it in GitHub Desktop.
log role changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `tgstation13`.`ss13role_time_log` ( `id` BIGINT NOT NULL AUTO_INCREMENT , `ckey` VARCHAR(32) NOT NULL , `job` VARCHAR(128) NOT NULL , `delta` INT NOT NULL , `datetime` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY (`id`), INDEX (`ckey`), INDEX (`job`), INDEX (`datetime`)) ENGINE = InnoDB; | |
DELIMITER | |
$$ | |
CREATE TRIGGER `tgstation13`.`ss13role_timeTlogupdate` | |
AFTER UPDATE | |
ON `tgstation13`.`ss13role_time` FOR EACH ROW | |
BEGIN | |
INSERT into ss13role_time_log (ckey, job, delta) VALUES (NEW.CKEY, NEW.job, NEW.minutes-OLD.minutes); | |
END | |
$$ | |
CREATE TRIGGER `tgstation13`.`ss13role_timeTloginsert` | |
AFTER INSERT | |
ON `tgstation13`.`ss13role_time` FOR EACH ROW | |
BEGIN | |
INSERT into ss13role_time_log (ckey, job, delta) VALUES (NEW.ckey, NEW.job, NEW.minutes); | |
END | |
$$ | |
CREATE TRIGGER `tgstation13`.`ss13role_timeTlogdelete` | |
AFTER DELETE | |
ON `tgstation13`.`ss13role_time` FOR EACH ROW | |
BEGIN | |
INSERT into ss13role_time_log (ckey, job, delta) VALUES (OLD.ckey, OLD.job, 0-OLD.minutes); | |
END | |
$$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment