Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
log role changes
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
You can’t perform that action at this time.