Files
Bubberstation/SQL/skyrat_schema.sql
GoldenAlpharex 1b17b304f2 SQL-Based Player Ranks and Player Ranks Subsystem (#23099)
* Initial draft, most of the stuff is implemented, not really tested or cleaned up yet

* Refactors the handling into a datum-based approach, for more abstraction

* Added migration, properly hooked up the verb to the new system

* Removed some more dead code

* Fixes some missing stuff from the .dme because VSC is stupid sometimes with merge conflicts

* Fixes the schema

* Wow I was really getting tired huh

* A fool, I say, a fool!

* I hate lists of lists I hate lists of lists I hate lists of lists

* I somehow missed this one twice. TWICE!

* This won't actually work if it's defaulting to true, lmao

* Makes it not log stuff if the adding or removing of players is unsuccessful

* Adds a way to update all of the unlock_contents for preferences datums once the donator list is initialized

* Runs update_prefs_unlock_content on mob Login() (hopefully this helps)

* Fixes the bajillion of runtimes caused by my dumb ass trying to make some client calls on ckeys

* Man I was really tired that day

* I had this ready for three hours and forgot to push it
2023-08-29 16:12:01 +02:00

83 lines
3.0 KiB
SQL

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `player_rank`.
--
DROP TABLE IF EXISTS `player_rank`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `player_rank` (
`ckey` VARCHAR(32) NOT NULL,
`rank` VARCHAR(12) NOT NULL,
`admin_ckey` VARCHAR(32) NOT NULL,
`date_added` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted` BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (`ckey`, `rank`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `player_rank_log`.
--
DROP TABLE IF EXISTS `player_rank_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `player_rank_log` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`ckey` VARCHAR(32) NOT NULL,
`rank` VARCHAR(12) NOT NULL,
`admin_ckey` VARCHAR(32) NOT NULL,
`action` ENUM('ADDED', 'REMOVED') NOT NULL DEFAULT 'ADDED',
`date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Trigger structure for trigger `log_player_rank_additions`.
--
DROP TRIGGER IF EXISTS `log_player_rank_additions`;
CREATE TRIGGER `log_player_rank_additions`
AFTER INSERT ON `player_rank`
FOR EACH ROW
INSERT INTO player_rank_log (ckey, rank, admin_ckey, `action`) VALUES (NEW.ckey, NEW.rank, NEW.admin_ckey, 'ADDED');
--
-- Trigger structure for trigger `log_player_rank_changes`.
--
DROP TRIGGER IF EXISTS `log_player_rank_changes`;
DELIMITER //
CREATE TRIGGER `log_player_rank_changes`
AFTER UPDATE ON `player_rank`
FOR EACH ROW
BEGIN
IF NEW.deleted = 1 THEN
INSERT INTO player_rank_log (ckey, rank, admin_ckey, `action`) VALUES (NEW.ckey, NEW.rank, NEW.admin_ckey, 'REMOVED');
ELSE
INSERT INTO player_rank_log (ckey, rank, admin_ckey, `action`) VALUES (NEW.ckey, NEW.rank, NEW.admin_ckey, 'ADDED');
END IF;
END; //
DELIMITER ;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;