[admin] Record player living playtime in notes (#18519)

* Record player living playtime in notes

* Updated to be trigger

* Fixed error in schema, oops

* Create trigger after the table it references like a smart person

* I'm a massive dunce

* Case
This commit is contained in:
adamsong
2023-04-24 13:11:46 -04:00
committed by GitHub
parent c5a8696ab3
commit b6c3e38535
6 changed files with 28 additions and 7 deletions

View File

@@ -1,13 +1,20 @@
Any time you make a change to the schema files, remember to increment the database schema version. Generally increment the minor number, major should be reserved for significant changes to the schema. Both values go up to 255.
The latest database version is 5.11; The query to update the schema revision table is:
The latest database version is 5.12; The query to update the schema revision table is:
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 11);
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 12);
or
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 11);
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 12);
In any query remember to add a prefix to the table names if you use one.
version 5.12 2023-04-10
Adds playtime to notes
ALTER TABLE `messages` ADD `playtime` int(10) unsigned DEFAULT NULL;
CREATE TRIGGER messagesTloghours
BEFORE INSERT ON `messages` FOR EACH ROW
SET NEW.playtime = (SELECT minutes FROM role_time rt WHERE rt.ckey = NEW.targetckey AND rt.job = 'Living');
version 5.11 2023-01-03
Adds comment to credentials binding

View File

@@ -326,6 +326,7 @@ CREATE TABLE IF NOT EXISTS `messages` (
`lasteditor` varchar(32) DEFAULT NULL,
`edits` mediumtext DEFAULT NULL,
`deleted` tinyint(3) unsigned NOT NULL DEFAULT 0,
`playtime` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_msg_ckey_time` (`targetckey`,`timestamp`,`deleted`),
KEY `idx_msg_type_ckeys_time` (`type`,`targetckey`,`adminckey`,`timestamp`,`deleted`),
@@ -560,6 +561,11 @@ END//
DELIMITER ;
SET SQL_MODE=@OLDTMP_SQL_MODE;
DROP TRIGGER IF EXISTS `messagesTloghours`;
CREATE TRIGGER `messagesTloghours`
BEFORE INSERT ON `messages` FOR EACH ROW
SET NEW.playtime = (SELECT minutes FROM role_time rt WHERE rt.ckey = NEW.targetckey AND rt.job = 'Living');
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

View File

@@ -326,6 +326,7 @@ CREATE TABLE IF NOT EXISTS `SS13_messages` (
`lasteditor` varchar(32) DEFAULT NULL,
`edits` mediumtext DEFAULT NULL,
`deleted` tinyint(3) unsigned NOT NULL DEFAULT 0,
`playtime` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_msg_ckey_time` (`targetckey`,`timestamp`,`deleted`),
KEY `idx_msg_type_ckeys_time` (`type`,`targetckey`,`adminckey`,`timestamp`,`deleted`),
@@ -560,6 +561,11 @@ END//
DELIMITER ;
SET SQL_MODE=@OLDTMP_SQL_MODE;
DROP TRIGGER IF EXISTS messagesTloghours;
CREATE TRIGGER messagesTloghours
BEFORE INSERT ON `SS13_messages` FOR EACH ROW
SET NEW.playtime = (SELECT minutes FROM SS13_role_time rt WHERE rt.ckey = NEW.targetckey AND rt.job = 'Living');
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;