From 6fed1764a943b6034cdbf0428f2bb87ae63efde8 Mon Sep 17 00:00:00 2001 From: Elson Costa Date: Wed, 29 May 2024 17:08:03 -0300 Subject: [PATCH] fix: schema query (#2664) --- data-otservbr-global/migrations/45.lua | 10 ++--- schema.sql | 62 +++++++++++++------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/data-otservbr-global/migrations/45.lua b/data-otservbr-global/migrations/45.lua index c606f18522e..4ceb5f7e3fd 100644 --- a/data-otservbr-global/migrations/45.lua +++ b/data-otservbr-global/migrations/45.lua @@ -3,7 +3,7 @@ function onUpdateDatabase() db.query([[ CREATE TABLE IF NOT EXISTS `account_vipgroups` ( - `id` tinyint(3) UNSIGNED NOT NULL, + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose vip group entry it is', `name` varchar(128) NOT NULL, `customizable` BOOLEAN NOT NULL DEFAULT '1', @@ -13,9 +13,9 @@ function onUpdateDatabase() db.query([[ CREATE TRIGGER `oncreate_accounts` AFTER INSERT ON `accounts` FOR EACH ROW BEGIN - INSERT INTO `account_vipgroups` (`id`, `account_id`, `name`, `customizable`) VALUES (1, NEW.`id`, 'Enemies', 0); - INSERT INTO `account_vipgroups` (`id`, `account_id`, `name`, `customizable`) VALUES (2, NEW.`id`, 'Friends', 0); - INSERT INTO `account_vipgroups` (`id`, `account_id`, `name`, `customizable`) VALUES (3, NEW.`id`, 'Trading Partner', 0); + INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Enemies', 0); + INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Friends', 0); + INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Trading Partner', 0); END; ]]) @@ -23,7 +23,7 @@ function onUpdateDatabase() CREATE TABLE IF NOT EXISTS `account_vipgrouplist` ( `account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose viplist entry it is', `player_id` int(11) NOT NULL COMMENT 'id of target player of viplist entry', - `vipgroup_id` tinyint(3) UNSIGNED NOT NULL COMMENT 'id of vip group that player belongs', + `vipgroup_id` int(11) UNSIGNED NOT NULL COMMENT 'id of vip group that player belongs', INDEX `account_id` (`account_id`), INDEX `player_id` (`player_id`), INDEX `vipgroup_id` (`vipgroup_id`), diff --git a/schema.sql b/schema.sql index bf37d1c2f37..2fbc7dd649b 100644 --- a/schema.sql +++ b/schema.sql @@ -217,7 +217,7 @@ CREATE TABLE IF NOT EXISTS `account_viplist` ( -- Table structure `account_vipgroup` CREATE TABLE IF NOT EXISTS `account_vipgroups` ( - `id` tinyint(3) UNSIGNED NOT NULL, + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose vip group entry it is', `name` varchar(128) NOT NULL, `customizable` BOOLEAN NOT NULL DEFAULT '1', @@ -229,9 +229,9 @@ CREATE TABLE IF NOT EXISTS `account_vipgroups` ( -- DELIMITER // CREATE TRIGGER `oncreate_accounts` AFTER INSERT ON `accounts` FOR EACH ROW BEGIN - INSERT INTO `account_vipgroups` (`id`, `account_id`, `name`, `customizable`) VALUES (1, NEW.`id`, 'Enemies', 0); - INSERT INTO `account_vipgroups` (`id`, `account_id`, `name`, `customizable`) VALUES (2, NEW.`id`, 'Friends', 0); - INSERT INTO `account_vipgroups` (`id`, `account_id`, `name`, `customizable`) VALUES (3, NEW.`id`, 'Trading Partner', 0); + INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Enemies', 0); + INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Friends', 0); + INSERT INTO `account_vipgroups` (`account_id`, `name`, `customizable`) VALUES (NEW.`id`, 'Trading Partner', 0); END // DELIMITER ; @@ -240,7 +240,7 @@ DELIMITER ; CREATE TABLE IF NOT EXISTS `account_vipgrouplist` ( `account_id` int(11) UNSIGNED NOT NULL COMMENT 'id of account whose viplist entry it is', `player_id` int(11) NOT NULL COMMENT 'id of target player of viplist entry', - `vipgroup_id` tinyint(3) UNSIGNED NOT NULL COMMENT 'id of vip group that player belongs', + `vipgroup_id` int(11) UNSIGNED NOT NULL COMMENT 'id of vip group that player belongs', INDEX `account_id` (`account_id`), INDEX `player_id` (`player_id`), INDEX `vipgroup_id` (`vipgroup_id`), @@ -258,35 +258,36 @@ CREATE TABLE IF NOT EXISTS `boosted_boss` ( `boostname` TEXT, `date` varchar(250) NOT NULL DEFAULT '', `raceid` varchar(250) NOT NULL DEFAULT '', - `looktypeEx` int(11) NOT NULL DEFAULT "0", - `looktype` int(11) NOT NULL DEFAULT "136", - `lookfeet` int(11) NOT NULL DEFAULT "0", - `looklegs` int(11) NOT NULL DEFAULT "0", - `lookhead` int(11) NOT NULL DEFAULT "0", - `lookbody` int(11) NOT NULL DEFAULT "0", - `lookaddons` int(11) NOT NULL DEFAULT "0", - `lookmount` int(11) DEFAULT "0", + `looktypeEx` int(11) NOT NULL DEFAULT 0, + `looktype` int(11) NOT NULL DEFAULT 136, + `lookfeet` int(11) NOT NULL DEFAULT 0, + `looklegs` int(11) NOT NULL DEFAULT 0, + `lookhead` int(11) NOT NULL DEFAULT 0, + `lookbody` int(11) NOT NULL DEFAULT 0, + `lookaddons` int(11) NOT NULL DEFAULT 0, + `lookmount` int(11) DEFAULT 0, PRIMARY KEY (`date`) -) AS SELECT 0 AS date, "default" AS boostname, 0 AS raceid; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `boosted_boss` (`boostname`, `date`, `raceid`) VALUES ('default', 0, 0); -- Table structure `boosted_creature` CREATE TABLE IF NOT EXISTS `boosted_creature` ( `boostname` TEXT, `date` varchar(250) NOT NULL DEFAULT '', `raceid` varchar(250) NOT NULL DEFAULT '', - `looktype` int(11) NOT NULL DEFAULT "136", - `lookfeet` int(11) NOT NULL DEFAULT "0", - `looklegs` int(11) NOT NULL DEFAULT "0", - `lookhead` int(11) NOT NULL DEFAULT "0", - `lookbody` int(11) NOT NULL DEFAULT "0", - `lookaddons` int(11) NOT NULL DEFAULT "0", - `lookmount` int(11) DEFAULT "0", + `looktype` int(11) NOT NULL DEFAULT 136, + `lookfeet` int(11) NOT NULL DEFAULT 0, + `looklegs` int(11) NOT NULL DEFAULT 0, + `lookhead` int(11) NOT NULL DEFAULT 0, + `lookbody` int(11) NOT NULL DEFAULT 0, + `lookaddons` int(11) NOT NULL DEFAULT 0, + `lookmount` int(11) DEFAULT 0, PRIMARY KEY (`date`) -) AS SELECT 0 AS date, "default" AS boostname, 0 AS raceid; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- -------------------------------------------------------- +INSERT INTO `boosted_creature` (`boostname`, `date`, `raceid`) VALUES ('default', 0, 0); --- -- Tabble Structure `daily_reward_history` CREATE TABLE IF NOT EXISTS `daily_reward_history` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -473,7 +474,6 @@ END DELIMITER ; -- Table structure `house_lists` - CREATE TABLE IF NOT EXISTS `house_lists` ( `house_id` int NOT NULL, `listid` int NOT NULL, @@ -485,7 +485,6 @@ CREATE TABLE IF NOT EXISTS `house_lists` ( CONSTRAINT `houses_list_house_fk` FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; - -- Table structure `ip_bans` CREATE TABLE IF NOT EXISTS `ip_bans` ( `ip` int(11) NOT NULL, @@ -540,7 +539,6 @@ CREATE TABLE IF NOT EXISTS `market_offers` ( ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- Table structure `players_online` CREATE TABLE IF NOT EXISTS `players_online` ( `player_id` int(11) NOT NULL, @@ -671,7 +669,6 @@ CREATE TABLE IF NOT EXISTS `player_wheeldata` ( PRIMARY KEY (`player_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- Table structure `player_kills` CREATE TABLE IF NOT EXISTS `player_kills` ( `player_id` int(11) NOT NULL, @@ -830,6 +827,7 @@ CREATE TABLE IF NOT EXISTS `account_sessions` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- Table structure `kv_store` CREATE TABLE IF NOT EXISTS `kv_store` ( `key_name` varchar(191) NOT NULL, `timestamp` bigint NOT NULL, @@ -854,7 +852,7 @@ INSERT INTO `players` (6, 'GOD', 6, 1, 2, 0, 155, 155, 100, 113, 115, 95, 39, 75, 0, 60, 60, 0, 8, '', 410, 1, 10, 0, 10, 0, 10, 0, 10, 0); -- Create vip groups for GOD account -INSERT INTO `account_vipgroups` (`id`, `name`, `account_id`, `customizable`) VALUES -(1, 'Friends', 1, 0), -(2, 'Enemies', 1, 0), -(3, 'Trading Partners', 1, 0); +INSERT INTO `account_vipgroups` (`name`, `account_id`, `customizable`) VALUES +('Friends', 1, 0), +('Enemies', 1, 0), +('Trading Partners', 1, 0);