From fc9f9604b0cc6cd678920767d4cdf0b4e47e93b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Lu=C3=ADs=20Lucarelo=20Lamonato?= Date: Thu, 19 Oct 2023 09:22:50 -0300 Subject: [PATCH 1/6] Update schema.sql The column is defined with the type int, which receives a maximum value of 4.294.967.295. Therefore, it was showing an error when saving the database table. The solution I found was to change the type of the version column from INT to BIGINT. --- schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index b54d9e2990a..8d479567abf 100644 --- a/schema.sql +++ b/schema.sql @@ -438,7 +438,7 @@ DELIMITER ; CREATE TABLE IF NOT EXISTS `house_lists` ( `house_id` int NOT NULL, `listid` int NOT NULL, - `version` int NOT NULL DEFAULT '0', + `version` bigint NOT NULL DEFAULT '0', `list` text NOT NULL, PRIMARY KEY (`house_id`, `listid`), KEY `house_id_index` (`house_id`), From 57dfdfbc6345a679090d9e7a4e9e5db1b383ff16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Lu=C3=ADs=20Lucarelo=20Lamonato?= Date: Fri, 20 Oct 2023 09:34:05 -0300 Subject: [PATCH 2/6] Update schema.sql --- schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index 8d479567abf..538dd9ecfff 100644 --- a/schema.sql +++ b/schema.sql @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS `server_config` ( CONSTRAINT `server_config_pk` PRIMARY KEY (`config`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '38'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); +INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '40'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); -- Table structure `accounts` CREATE TABLE IF NOT EXISTS `accounts` ( From d2c48c802f2f4597a46196a505b4bf61bbebd0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Lu=C3=ADs=20Lucarelo=20Lamonato?= Date: Fri, 20 Oct 2023 09:45:33 -0300 Subject: [PATCH 3/6] some fixes --- data-otservbr-global/migrations/40.lua | 10 +++++++--- schema.sql | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/data-otservbr-global/migrations/40.lua b/data-otservbr-global/migrations/40.lua index 6e9828d66b7..76fca3ec37f 100644 --- a/data-otservbr-global/migrations/40.lua +++ b/data-otservbr-global/migrations/40.lua @@ -1,8 +1,5 @@ function onUpdateDatabase() logger.info("Updating database to version 41 (optimize house_lists)") - db.query([[ - ALTER TABLE `house_lists` DROP COLUMN `id`; - ]]) db.query([[ ALTER TABLE `house_lists` @@ -10,5 +7,12 @@ function onUpdateDatabase() ADD INDEX `version` (`version`), ADD PRIMARY KEY (`house_id`, `listid`); ]]) + + + db.query([[ + ALTER TABLE house_lists + CHANGE version version BIGINT(20) + NOT NULL DEFAULT '0'; + ]]) return true end diff --git a/schema.sql b/schema.sql index 538dd9ecfff..dc58d3a71ac 100644 --- a/schema.sql +++ b/schema.sql @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS `server_config` ( CONSTRAINT `server_config_pk` PRIMARY KEY (`config`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '40'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); +INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '41'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); -- Table structure `accounts` CREATE TABLE IF NOT EXISTS `accounts` ( From e8ee9bec24b32790b3526915a310133e6675f5d9 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 20 Oct 2023 12:46:44 +0000 Subject: [PATCH 4/6] Lua code format - (Stylua) --- data-otservbr-global/migrations/40.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/data-otservbr-global/migrations/40.lua b/data-otservbr-global/migrations/40.lua index 76fca3ec37f..d153f318a5a 100644 --- a/data-otservbr-global/migrations/40.lua +++ b/data-otservbr-global/migrations/40.lua @@ -8,7 +8,6 @@ function onUpdateDatabase() ADD PRIMARY KEY (`house_id`, `listid`); ]]) - db.query([[ ALTER TABLE house_lists CHANGE version version BIGINT(20) From 5d382babbd3ac0d8e564b106bf6b54006e8ae1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Lu=C3=ADs=20Lucarelo=20Lamonato?= Date: Fri, 20 Oct 2023 13:42:47 -0300 Subject: [PATCH 5/6] Update 40.lua --- data-otservbr-global/migrations/40.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data-otservbr-global/migrations/40.lua b/data-otservbr-global/migrations/40.lua index d153f318a5a..aa889de5e44 100644 --- a/data-otservbr-global/migrations/40.lua +++ b/data-otservbr-global/migrations/40.lua @@ -9,9 +9,9 @@ function onUpdateDatabase() ]]) db.query([[ - ALTER TABLE house_lists - CHANGE version version BIGINT(20) - NOT NULL DEFAULT '0'; + ALTER TABLE `house_lists` + MODIFY `version` bigint(20) NOT NULL DEFAULT '0'; ]]) + return true end From 2c74204b5285ec34c88752d4fd892fc4418cb666 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 20 Oct 2023 16:44:00 +0000 Subject: [PATCH 6/6] Lua code format - (Stylua) --- data-otservbr-global/migrations/40.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-otservbr-global/migrations/40.lua b/data-otservbr-global/migrations/40.lua index aa889de5e44..22bfea0da95 100644 --- a/data-otservbr-global/migrations/40.lua +++ b/data-otservbr-global/migrations/40.lua @@ -12,6 +12,6 @@ function onUpdateDatabase() ALTER TABLE `house_lists` MODIFY `version` bigint(20) NOT NULL DEFAULT '0'; ]]) - + return true end