From 8a3a03e0a6e5f9fe77d0835344920d3271ea33e9 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sat, 24 Jul 2010 18:46:36 +0400 Subject: [PATCH] [10263] Not allow listing pool elements in more one pool. NOTE: sql update remove forbided by commit duplicates from pool_* tables in random way. So for more porper results DB better manually check and fix before apply it. This is mostly note for DB projects devs. --- sql/mangos.sql | 13 +++++++------ sql/updates/10263_01_mangos_pool_creature.sql | 12 ++++++++++++ sql/updates/10263_02_mangos_pool_gameobject.sql | 12 ++++++++++++ sql/updates/10263_03_mangos_pool_pool.sql | 12 ++++++++++++ sql/updates/Makefile.am | 6 ++++++ src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 7 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 sql/updates/10263_01_mangos_pool_creature.sql create mode 100644 sql/updates/10263_02_mangos_pool_gameobject.sql create mode 100644 sql/updates/10263_03_mangos_pool_pool.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index a789eb5c7..5e14b5816 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_10257_01_mangos_command` bit(1) default NULL + `required_10263_03_mangos_pool_pool` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -13608,8 +13608,8 @@ CREATE TABLE `pool_creature` ( `pool_entry` mediumint(8) unsigned NOT NULL default '0', `chance` float unsigned NOT NULL default '0', `description` varchar(255) NOT NULL, - PRIMARY KEY (`pool_entry`,`guid`), - INDEX `idx_guid`(`guid`) + PRIMARY KEY (`guid`), + INDEX `pool_idx` (pool_entry) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; @@ -13632,8 +13632,8 @@ CREATE TABLE `pool_gameobject` ( `pool_entry` mediumint(8) unsigned NOT NULL default '0', `chance` float unsigned NOT NULL default '0', `description` varchar(255) NOT NULL, - PRIMARY KEY (`guid`,`pool_entry`), - INDEX `idx_guid`(`guid`) + PRIMARY KEY (`guid`), + INDEX `pool_idx` (pool_entry) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- @@ -13655,7 +13655,8 @@ CREATE TABLE `pool_pool` ( `mother_pool` mediumint(8) unsigned NOT NULL default '0', `chance` float NOT NULL default '0', `description` varchar(255) NOT NULL, - PRIMARY KEY (`pool_id`,`mother_pool`) + PRIMARY KEY (pool_id), + INDEX pool_idx (mother_pool) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- diff --git a/sql/updates/10263_01_mangos_pool_creature.sql b/sql/updates/10263_01_mangos_pool_creature.sql new file mode 100644 index 000000000..2621c3336 --- /dev/null +++ b/sql/updates/10263_01_mangos_pool_creature.sql @@ -0,0 +1,12 @@ +ALTER TABLE db_version CHANGE COLUMN required_10257_01_mangos_command required_10263_01_mangos_pool_creature bit; + +DROP TABLE IF EXISTS pool_creature_temp; +CREATE TABLE pool_creature_temp +SELECT guid, pool_entry, chance, description FROM pool_creature GROUP BY guid; + +ALTER TABLE pool_creature_temp + ADD PRIMARY KEY (guid), + ADD INDEX pool_idx (pool_entry); + +DROP TABLE IF EXISTS pool_creature; +RENAME TABLE pool_creature_temp TO pool_creature; diff --git a/sql/updates/10263_02_mangos_pool_gameobject.sql b/sql/updates/10263_02_mangos_pool_gameobject.sql new file mode 100644 index 000000000..bf1f0aa52 --- /dev/null +++ b/sql/updates/10263_02_mangos_pool_gameobject.sql @@ -0,0 +1,12 @@ +ALTER TABLE db_version CHANGE COLUMN required_10263_01_mangos_pool_creature required_10263_02_mangos_pool_gameobject bit; + +DROP TABLE IF EXISTS pool_gameobject_temp; +CREATE TABLE pool_gameobject_temp +SELECT guid, pool_entry, chance, description FROM pool_gameobject GROUP BY guid; + +ALTER TABLE pool_gameobject_temp + ADD PRIMARY KEY (guid), + ADD INDEX pool_idx (pool_entry); + +DROP TABLE IF EXISTS pool_gameobject; +RENAME TABLE pool_gameobject_temp TO pool_gameobject; diff --git a/sql/updates/10263_03_mangos_pool_pool.sql b/sql/updates/10263_03_mangos_pool_pool.sql new file mode 100644 index 000000000..8940b2617 --- /dev/null +++ b/sql/updates/10263_03_mangos_pool_pool.sql @@ -0,0 +1,12 @@ +ALTER TABLE db_version CHANGE COLUMN required_10263_02_mangos_pool_gameobject required_10263_03_mangos_pool_pool bit; + +DROP TABLE IF EXISTS pool_pool_temp; +CREATE TABLE pool_pool_temp +SELECT pool_id, mother_pool, chance, description FROM pool_pool GROUP BY pool_id; + +ALTER TABLE pool_pool_temp + ADD PRIMARY KEY (pool_id), + ADD INDEX pool_idx (mother_pool); + +DROP TABLE IF EXISTS pool_pool; +RENAME TABLE pool_pool_temp TO pool_pool; diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 3a7cf6535..d6c65b42c 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -53,6 +53,9 @@ pkgdata_DATA = \ 10254_01_characters_auctionhouse.sql \ 10256_01_mangos_command.sql \ 10257_01_mangos_command.sql \ + 10263_01_mangos_pool_creature.sql \ + 10263_02_mangos_pool_gameobject.sql \ + 10263_03_mangos_pool_pool.sql \ README ## Additional files to include when running 'make dist' @@ -86,4 +89,7 @@ EXTRA_DIST = \ 10254_01_characters_auctionhouse.sql \ 10256_01_mangos_command.sql \ 10257_01_mangos_command.sql \ + 10263_01_mangos_pool_creature.sql \ + 10263_02_mangos_pool_gameobject.sql \ + 10263_03_mangos_pool_pool.sql \ README diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c7935e1af..3dd8d8672 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10262" + #define REVISION_NR "10263" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 3abb35e93..2d0228be2 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_10254_01_characters_auctionhouse" - #define REVISION_DB_MANGOS "required_10257_01_mangos_command" + #define REVISION_DB_MANGOS "required_10263_03_mangos_pool_pool" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__