Skip to content

Commit

Permalink
Make round ID nullable in bans and tickets (tgstation#61985)
Browse files Browse the repository at this point in the history
* Make round ID nullable in bans and tickets

* Apply to everything

* Jordie's feedback

* Change NOT NULL in admig_log
  • Loading branch information
Mothblocks authored Oct 12, 2021
1 parent 696cdf9 commit da1a809
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 27 deletions.
25 changes: 22 additions & 3 deletions SQL/database_changelog.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
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.16; The query to update the schema revision table is:
The latest database version is 5.17; The query to update the schema revision table is:

INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 16);
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 17);
or
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 16);
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 17);

In any query remember to add a prefix to the table names if you use one.

-----------------------------------------------------
Version 5.17, 8 October 2021, by MrStonedOne + Mothblocks
Changes any table that requrired a NOT NULL round ID to now accept NULL. In the BSQL past, these were handled as 0, but in the move to rust-g this behavior was lost.

```
ALTER TABLE `admin_log` CHANGE `round_id` `round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `ban` CHANGE `round_id` `round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `citation` CHANGE `round_id` `round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `connection_log` CHANGE `round_id` `round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `death` CHANGE `round_id` `round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `feedback` CHANGE `round_id` `round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `legacy_population` CHANGE `round_id` `round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `library` CHANGE `round_id_created` `round_id_created` INT(11) UNSIGNED NULL;
ALTER TABLE `messages` CHANGE `round_id` `round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `player` CHANGE `firstseen_round_id` `firstseen_round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `player` CHANGE `lastseen_round_id` `lastseen_round_id` INT(11) UNSIGNED NULL;
ALTER TABLE `ticket` CHANGE `round_id` `round_id` INT(11) UNSIGNED NULL;
```

-----------------------------------------------------
Version 5.16, 31 July 2021, by Atlanta-Ned
Added `library_action` table for tracking reported library books and actions taken on them.
Expand Down
24 changes: 12 additions & 12 deletions SQL/tgstation_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DROP TABLE IF EXISTS `admin_log`;
CREATE TABLE `admin_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`datetime` datetime NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`adminckey` varchar(32) NOT NULL,
`adminip` int(10) unsigned NOT NULL,
`operation` enum('add admin','remove admin','change admin rank','add rank','remove rank','change rank flags') NOT NULL,
Expand Down Expand Up @@ -72,7 +72,7 @@ CREATE TABLE `ban` (
`bantime` DATETIME NOT NULL,
`server_ip` INT(10) UNSIGNED NOT NULL,
`server_port` SMALLINT(5) UNSIGNED NOT NULL,
`round_id` INT(11) UNSIGNED NOT NULL,
`round_id` INT(11) UNSIGNED NULL,
`role` VARCHAR(32) NULL DEFAULT NULL,
`expiration_time` DATETIME NULL DEFAULT NULL,
`applies_to_admins` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
Expand Down Expand Up @@ -106,7 +106,7 @@ DROP TABLE IF EXISTS `citation`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `citation` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`server_ip` int(11) unsigned NOT NULL,
`server_port` int(11) unsigned NOT NULL,
`citation` text NOT NULL,
Expand Down Expand Up @@ -135,7 +135,7 @@ CREATE TABLE `connection_log` (
`datetime` datetime DEFAULT NULL,
`server_ip` int(10) unsigned NOT NULL,
`server_port` smallint(5) unsigned NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`ckey` varchar(45) DEFAULT NULL,
`ip` int(10) unsigned NOT NULL,
`computerid` varchar(45) DEFAULT NULL,
Expand All @@ -159,7 +159,7 @@ CREATE TABLE `death` (
`mapname` varchar(32) NOT NULL,
`server_ip` int(10) unsigned NOT NULL,
`server_port` smallint(5) unsigned NOT NULL,
`round_id` int(11) NOT NULL,
`round_id` int(11) unsigned NULL,
`tod` datetime NOT NULL COMMENT 'Time of death',
`job` varchar(32) NOT NULL,
`special` varchar(32) DEFAULT NULL,
Expand Down Expand Up @@ -190,7 +190,7 @@ DROP TABLE IF EXISTS `feedback`;
CREATE TABLE `feedback` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`datetime` datetime NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`key_name` varchar(32) NOT NULL,
`key_type` enum('text', 'amount', 'tally', 'nested tally', 'associative') NOT NULL,
`version` tinyint(3) unsigned NOT NULL,
Expand Down Expand Up @@ -229,7 +229,7 @@ CREATE TABLE `legacy_population` (
`time` datetime NOT NULL,
`server_ip` int(10) unsigned NOT NULL,
`server_port` smallint(5) unsigned NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
Expand All @@ -250,7 +250,7 @@ CREATE TABLE `library` (
`ckey` varchar(32) NOT NULL DEFAULT 'LEGACY',
`datetime` datetime NOT NULL,
`deleted` tinyint(1) unsigned DEFAULT NULL,
`round_id_created` int(11) unsigned NOT NULL,
`round_id_created` int(11) unsigned NULL,
PRIMARY KEY (`id`),
KEY `deleted_idx` (`deleted`),
KEY `idx_lib_id_del` (`id`,`deleted`),
Expand Down Expand Up @@ -295,7 +295,7 @@ CREATE TABLE `messages` (
`server` varchar(32) DEFAULT NULL,
`server_ip` int(10) unsigned NOT NULL,
`server_port` smallint(5) unsigned NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`secret` tinyint(1) unsigned NOT NULL,
`expire_timestamp` datetime DEFAULT NULL,
`severity` enum('high','medium','minor','none') DEFAULT NULL,
Expand Down Expand Up @@ -359,9 +359,9 @@ CREATE TABLE `player` (
`ckey` varchar(32) NOT NULL,
`byond_key` varchar(32) DEFAULT NULL,
`firstseen` datetime NOT NULL,
`firstseen_round_id` int(11) unsigned NOT NULL,
`firstseen_round_id` int(11) unsigned NULL,
`lastseen` datetime NOT NULL,
`lastseen_round_id` int(11) unsigned NOT NULL,
`lastseen_round_id` int(11) unsigned NULL,
`ip` int(10) unsigned NOT NULL,
`computerid` varchar(32) NOT NULL,
`lastadminrank` varchar(32) NOT NULL DEFAULT 'Player',
Expand Down Expand Up @@ -585,7 +585,7 @@ CREATE TABLE `ticket` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`server_ip` int(10) unsigned NOT NULL,
`server_port` smallint(5) unsigned NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`ticket` smallint(11) unsigned NOT NULL,
`action` varchar(20) NOT NULL DEFAULT 'Message',
`message` text NOT NULL,
Expand Down
22 changes: 11 additions & 11 deletions SQL/tgstation_schema_prefixed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DROP TABLE IF EXISTS `SS13_admin_log`;
CREATE TABLE `SS13_admin_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`datetime` datetime NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`adminckey` varchar(32) NOT NULL,
`adminip` int(10) unsigned NOT NULL,
`operation` enum('add admin','remove admin','change admin rank','add rank','remove rank','change rank flags') NOT NULL,
Expand Down Expand Up @@ -72,7 +72,7 @@ CREATE TABLE `SS13_ban` (
`bantime` DATETIME NOT NULL,
`server_ip` INT(10) UNSIGNED NOT NULL,
`server_port` SMALLINT(5) UNSIGNED NOT NULL,
`round_id` INT(11) UNSIGNED NOT NULL,
`round_id` INT(11) UNSIGNED NULL,
`role` VARCHAR(32) NULL DEFAULT NULL,
`expiration_time` DATETIME NULL DEFAULT NULL,
`applies_to_admins` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
Expand Down Expand Up @@ -106,7 +106,7 @@ DROP TABLE IF EXISTS `SS13_citation`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `SS13_citation` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`server_ip` int(11) unsigned NOT NULL,
`server_port` int(11) unsigned NOT NULL,
`citation` text NOT NULL,
Expand Down Expand Up @@ -159,7 +159,7 @@ CREATE TABLE `SS13_death` (
`mapname` varchar(32) NOT NULL,
`server_ip` int(10) unsigned NOT NULL,
`server_port` smallint(5) unsigned NOT NULL,
`round_id` int(11) NOT NULL,
`round_id` int(11) NULL,
`tod` datetime NOT NULL COMMENT 'Time of death',
`job` varchar(32) NOT NULL,
`special` varchar(32) DEFAULT NULL,
Expand Down Expand Up @@ -190,7 +190,7 @@ DROP TABLE IF EXISTS `SS13_feedback`;
CREATE TABLE `SS13_feedback` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`datetime` datetime NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`key_name` varchar(32) NOT NULL,
`version` tinyint(3) unsigned NOT NULL,
`key_type` enum('text', 'amount', 'tally', 'nested tally', 'associative') NOT NULL,
Expand Down Expand Up @@ -229,7 +229,7 @@ CREATE TABLE `SS13_legacy_population` (
`time` datetime NOT NULL,
`server_ip` int(10) unsigned NOT NULL,
`server_port` smallint(5) unsigned NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
Expand All @@ -250,7 +250,7 @@ CREATE TABLE `SS13_library` (
`ckey` varchar(32) NOT NULL DEFAULT 'LEGACY',
`datetime` datetime NOT NULL,
`deleted` tinyint(1) unsigned DEFAULT NULL,
`round_id_created` int(11) unsigned NOT NULL,
`round_id_created` int(11) unsigned NULL,
PRIMARY KEY (`id`),
KEY `deleted_idx` (`deleted`),
KEY `idx_lib_id_del` (`id`,`deleted`),
Expand Down Expand Up @@ -295,7 +295,7 @@ CREATE TABLE `SS13_messages` (
`server` varchar(32) DEFAULT NULL,
`server_ip` int(10) unsigned NOT NULL,
`server_port` smallint(5) unsigned NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`secret` tinyint(1) unsigned NOT NULL,
`expire_timestamp` datetime DEFAULT NULL,
`severity` enum('high','medium','minor','none') DEFAULT NULL,
Expand Down Expand Up @@ -359,9 +359,9 @@ CREATE TABLE `SS13_player` (
`ckey` varchar(32) NOT NULL,
`byond_key` varchar(32) DEFAULT NULL,
`firstseen` datetime NOT NULL,
`firstseen_round_id` int(11) unsigned NOT NULL,
`firstseen_round_id` int(11) unsigned NULL,
`lastseen` datetime NOT NULL,
`lastseen_round_id` int(11) unsigned NOT NULL,
`lastseen_round_id` int(11) unsigned NULL,
`ip` int(10) unsigned NOT NULL,
`computerid` varchar(32) NOT NULL,
`lastadminrank` varchar(32) NOT NULL DEFAULT 'Player',
Expand Down Expand Up @@ -585,7 +585,7 @@ CREATE TABLE `SS13_ticket` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`server_ip` int(10) unsigned NOT NULL,
`server_port` smallint(5) unsigned NOT NULL,
`round_id` int(11) unsigned NOT NULL,
`round_id` int(11) unsigned NULL,
`ticket` smallint(11) unsigned NOT NULL,
`action` varchar(20) NOT NULL DEFAULT 'Message',
`message` text NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* make sure you add an update to the schema_version stable in the db changelog
*/
#define DB_MINOR_VERSION 16
#define DB_MINOR_VERSION 17


//! ## Timing subsystem
Expand Down

0 comments on commit da1a809

Please sign in to comment.