diff options
author | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-02-12 20:05:22 +0300 |
---|---|---|
committer | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-02-12 20:05:22 +0300 |
commit | ba7ffa13310b25046bc8461a77091f01f11de7cc (patch) | |
tree | 9babaf14919895d700f6c29ed064be48bb59ea22 /core/Updates | |
parent | 954ca26e3c12a9f716bcae90c57b80e6b6167d2d (diff) |
refs #1129, refs #1151 - refactoring to add getSql() to return array of SQL statements
Diffstat (limited to 'core/Updates')
-rw-r--r-- | core/Updates/0.2.10.php | 18 | ||||
-rw-r--r-- | core/Updates/0.2.12.php | 14 | ||||
-rw-r--r-- | core/Updates/0.2.13.php | 14 | ||||
-rw-r--r-- | core/Updates/0.2.24.php | 13 | ||||
-rw-r--r-- | core/Updates/0.2.27.php | 11 | ||||
-rw-r--r-- | core/Updates/0.2.32.php | 13 | ||||
-rw-r--r-- | core/Updates/0.2.33.php | 11 | ||||
-rw-r--r-- | core/Updates/0.2.34.php | 2 | ||||
-rw-r--r-- | core/Updates/0.2.35.php | 13 | ||||
-rw-r--r-- | core/Updates/0.2.37.php | 13 | ||||
-rw-r--r-- | core/Updates/0.4.1.php | 13 | ||||
-rw-r--r-- | core/Updates/0.4.2.php | 15 | ||||
-rw-r--r-- | core/Updates/0.4.4.php | 2 | ||||
-rw-r--r-- | core/Updates/0.4.php | 14 | ||||
-rw-r--r-- | core/Updates/0.5.4.php | 16 | ||||
-rw-r--r-- | core/Updates/0.5.5.php | 25 | ||||
-rw-r--r-- | core/Updates/0.5.php | 13 |
17 files changed, 155 insertions, 65 deletions
diff --git a/core/Updates/0.2.10.php b/core/Updates/0.2.10.php index 5bb5cb416d..746dfd751f 100644 --- a/core/Updates/0.2.10.php +++ b/core/Updates/0.2.10.php @@ -13,19 +13,19 @@ /** * @package Updates */ -class Piwik_Updates_0_2_10 implements Piwik_iUpdate +class Piwik_Updates_0_2_10 extends Piwik_Updates { - static function update() + static function getSql() { $tables = Piwik::getTablesCreateSql(); - Piwik_Updater::updateDatabase(__FILE__, array( + + return array( $tables['option'] => false, - )); - Piwik_Updater::updateDatabase(__FILE__, array( // 0.1.7 [463] 'ALTER IGNORE TABLE `'. Piwik::prefixTable('log_visit') .'` CHANGE `location_provider` `location_provider` VARCHAR( 100 ) DEFAULT NULL' => '1054', + // 0.1.7 [470] 'ALTER TABLE `'. Piwik::prefixTable('logger_api_call') .'` CHANGE `parameter_names_default_values` `parameter_names_default_values` TEXT, @@ -37,10 +37,16 @@ class Piwik_Updates_0_2_10 implements Piwik_iUpdate CHANGE `message` `message` TEXT' => false, 'ALTER TABLE `'. Piwik::prefixTable('logger_message') .'` CHANGE `message` `message` TEXT' => false, + // 0.2.2 [489] 'ALTER IGNORE TABLE `'. Piwik::prefixTable('site') .'` CHANGE `feedburnerName` `feedburnerName` VARCHAR( 100 ) DEFAULT NULL' => '1054', - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); $obsoleteFile = '/plugins/ExamplePlugin/API.php'; if(file_exists(PIWIK_INCLUDE_PATH . $obsoleteFile)) diff --git a/core/Updates/0.2.12.php b/core/Updates/0.2.12.php index a6ef7c0f99..e997eb6d88 100644 --- a/core/Updates/0.2.12.php +++ b/core/Updates/0.2.12.php @@ -13,18 +13,24 @@ /** * @package Updates */ -class Piwik_Updates_0_2_12 implements Piwik_iUpdate +class Piwik_Updates_0_2_12 extends Piwik_Updates { - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + return array( 'ALTER TABLE `'. Piwik::prefixTable('site') .'` CHANGE `ts_created` `ts_created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL' => false, 'ALTER TABLE `'. Piwik::prefixTable('log_visit') .'` DROP `config_color_depth`' => false, + // 0.2.12 [673] // Note: requires INDEX privilege 'DROP INDEX index_idaction ON `'. Piwik::prefixTable('log_action') .'`' => '1091', - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.2.13.php b/core/Updates/0.2.13.php index fb8a875f54..fc6b845af7 100644 --- a/core/Updates/0.2.13.php +++ b/core/Updates/0.2.13.php @@ -13,14 +13,20 @@ /** * @package Updates */ -class Piwik_Updates_0_2_13 implements Piwik_iUpdate +class Piwik_Updates_0_2_13 extends Piwik_Updates { - static function update() + static function getSql() { $tables = Piwik::getTablesCreateSql(); - Piwik_Updater::updateDatabase(__FILE__, array( + + return array( 'DROP TABLE IF EXISTS `'. Piwik::prefixTable('option') .'`' => false, $tables['option'] => false, - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.2.24.php b/core/Updates/0.2.24.php index a5a19837e6..e47092437f 100644 --- a/core/Updates/0.2.24.php +++ b/core/Updates/0.2.24.php @@ -13,17 +13,22 @@ /** * @package Updates */ -class Piwik_Updates_0_2_24 implements Piwik_iUpdate +class Piwik_Updates_0_2_24 extends Piwik_Updates { - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + return array( 'CREATE INDEX index_type_name ON '. Piwik::prefixTable('log_action') .' (type, name(15))' => false, 'CREATE INDEX index_idsite_date ON '. Piwik::prefixTable('log_visit') .' (idsite, visit_server_date)' => false, 'DROP INDEX index_idsite ON '. Piwik::prefixTable('log_visit') => false, 'DROP INDEX index_visit_server_date ON '. Piwik::prefixTable('log_visit') => false, - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.2.27.php b/core/Updates/0.2.27.php index ccc7bda3a7..6843816ae4 100644 --- a/core/Updates/0.2.27.php +++ b/core/Updates/0.2.27.php @@ -13,9 +13,9 @@ /** * @package Updates */ -class Piwik_Updates_0_2_27 implements Piwik_iUpdate +class Piwik_Updates_0_2_27 extends Piwik_Updates { - static function update() + static function getSql() { $sqlarray = array( 'ALTER TABLE `'. Piwik::prefixTable('log_visit') .'` @@ -38,6 +38,11 @@ class Piwik_Updates_0_2_27 implements Piwik_iUpdate } } - Piwik_Updater::updateDatabase(__FILE__, $sqlarray); + return $sqlarray; + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.2.32.php b/core/Updates/0.2.32.php index 8b5b99dabb..20f099d7fb 100644 --- a/core/Updates/0.2.32.php +++ b/core/Updates/0.2.32.php @@ -13,11 +13,11 @@ /** * @package Updates */ -class Piwik_Updates_0_2_32 implements Piwik_iUpdate +class Piwik_Updates_0_2_32 extends Piwik_Updates { - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + return array( // 0.2.32 [941] 'ALTER TABLE `'. Piwik::prefixTable('access') .'` CHANGE `login` `login` VARCHAR( 100 ) NOT NULL' => false, @@ -27,6 +27,11 @@ class Piwik_Updates_0_2_32 implements Piwik_iUpdate CHANGE `login` `login` VARCHAR( 100 ) NOT NULL' => '1146', 'ALTER TABLE `'. Piwik::prefixTable('user_language') .'` CHANGE `login` `login` VARCHAR( 100 ) NOT NULL' => '1146', - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.2.33.php b/core/Updates/0.2.33.php index 1f9487ba00..6de3721e78 100644 --- a/core/Updates/0.2.33.php +++ b/core/Updates/0.2.33.php @@ -13,9 +13,9 @@ /** * @package Updates */ -class Piwik_Updates_0_2_33 implements Piwik_iUpdate +class Piwik_Updates_0_2_33 extends Piwik_Updates { - static function update() + static function getSql() { $sqlarray = array( // 0.2.33 [1020] @@ -32,6 +32,11 @@ class Piwik_Updates_0_2_33 implements Piwik_iUpdate CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci ' ] = false; } - Piwik_Updater::updateDatabase(__FILE__, $sqlarray); + return $sqlarray; + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.2.34.php b/core/Updates/0.2.34.php index c76550a6b5..ca7ae16211 100644 --- a/core/Updates/0.2.34.php +++ b/core/Updates/0.2.34.php @@ -13,7 +13,7 @@ /** * @package Updates */ -class Piwik_Updates_0_2_34 implements Piwik_iUpdate +class Piwik_Updates_0_2_34 extends Piwik_Updates { static function update() { diff --git a/core/Updates/0.2.35.php b/core/Updates/0.2.35.php index 3fbeb4ab87..da53ec8874 100644 --- a/core/Updates/0.2.35.php +++ b/core/Updates/0.2.35.php @@ -13,13 +13,18 @@ /** * @package Updates */ -class Piwik_Updates_0_2_35 implements Piwik_iUpdate +class Piwik_Updates_0_2_35 extends Piwik_Updates { - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + return array( 'ALTER TABLE `'. Piwik::prefixTable('user_dashboard') .'` CHANGE `layout` `layout` TEXT NOT NULL' => false, - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.2.37.php b/core/Updates/0.2.37.php index ed1a36160d..42efc5f5e8 100644 --- a/core/Updates/0.2.37.php +++ b/core/Updates/0.2.37.php @@ -13,14 +13,19 @@ /** * @package Updates */ -class Piwik_Updates_0_2_37 implements Piwik_iUpdate +class Piwik_Updates_0_2_37 extends Piwik_Updates { - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + return array( 'DELETE FROM `'. Piwik::prefixTable('user_dashboard') ."` WHERE layout LIKE '%.getLastVisitsGraph%' OR layout LIKE '%.getLastVisitsReturningGraph%'" => false, - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.4.1.php b/core/Updates/0.4.1.php index 280a82d809..3aa0f102c3 100644 --- a/core/Updates/0.4.1.php +++ b/core/Updates/0.4.1.php @@ -13,15 +13,20 @@ /** * @package Updates */ -class Piwik_Updates_0_4_1 implements Piwik_iUpdate +class Piwik_Updates_0_4_1 extends Piwik_Updates { - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + return array( 'ALTER TABLE `'. Piwik::prefixTable('log_conversion') .'` CHANGE `idlink_va` `idlink_va` INT(11) DEFAULT NULL' => false, 'ALTER TABLE `'. Piwik::prefixTable('log_conversion') .'` CHANGE `idaction` `idaction` INT(11) DEFAULT NULL' => '1054', - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.4.2.php b/core/Updates/0.4.2.php index ef91786033..d1a34743dd 100644 --- a/core/Updates/0.4.2.php +++ b/core/Updates/0.4.2.php @@ -13,12 +13,11 @@ /** * @package Updates */ -class Piwik_Updates_0_4_2 implements Piwik_iUpdate +class Piwik_Updates_0_4_2 extends Piwik_Updates { - // when restoring (possibly) previousy dropped columns, ignore mysql code error 1060: duplicate column - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + return array( 'ALTER TABLE `'. Piwik::prefixTable('log_visit') .'` ADD `config_java` TINYINT(1) NOT NULL AFTER `config_flash`' => '1060', 'ALTER TABLE `'. Piwik::prefixTable('log_visit') .'` @@ -26,6 +25,12 @@ class Piwik_Updates_0_4_2 implements Piwik_iUpdate 'ALTER TABLE `'. Piwik::prefixTable('log_visit') .'` ADD `config_gears` TINYINT(1) NOT NULL AFTER `config_windowsmedia`, ADD `config_silverlight` TINYINT(1) NOT NULL AFTER `config_gears`' => false, - )); + ); + } + + // when restoring (possibly) previousy dropped columns, ignore mysql code error 1060: duplicate column + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.4.4.php b/core/Updates/0.4.4.php index d457d63652..da4cde9b28 100644 --- a/core/Updates/0.4.4.php +++ b/core/Updates/0.4.4.php @@ -13,7 +13,7 @@ /** * @package Updates */ -class Piwik_Updates_0_4_4 implements Piwik_iUpdate +class Piwik_Updates_0_4_4 extends Piwik_Updates { static function update() { diff --git a/core/Updates/0.4.php b/core/Updates/0.4.php index 5c779bf077..f616bce2d4 100644 --- a/core/Updates/0.4.php +++ b/core/Updates/0.4.php @@ -13,11 +13,11 @@ /** * @package Updates */ -class Piwik_Updates_0_4 implements Piwik_iUpdate +class Piwik_Updates_0_4 extends Piwik_Updates { - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + return array( 'UPDATE `'. Piwik::prefixTable('log_visit') .'` SET location_ip=location_ip+CAST(POW(2,32) AS UNSIGNED) WHERE location_ip < 0' => false, 'ALTER TABLE `'. Piwik::prefixTable('log_visit') .'` @@ -26,11 +26,17 @@ class Piwik_Updates_0_4 implements Piwik_iUpdate SET caller_ip=caller_ip+CAST(POW(2,32) AS UNSIGNED) WHERE caller_ip < 0' => false, 'ALTER TABLE `'. Piwik::prefixTable('logger_api_call') .'` CHANGE `caller_ip` `caller_ip` BIGINT UNSIGNED' => false, + // 0.4 [1140] 'ALTER TABLE `'. Piwik::prefixTable('log_visit') .'` CHANGE `location_ip` `location_ip` BIGINT UNSIGNED NOT NULL' => false, 'ALTER TABLE `'. Piwik::prefixTable('logger_api_call') .'` CHANGE `caller_ip` `caller_ip` BIGINT UNSIGNED' => false, - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.5.4.php b/core/Updates/0.5.4.php index d27a95d522..2b5f7601f1 100644 --- a/core/Updates/0.5.4.php +++ b/core/Updates/0.5.4.php @@ -13,8 +13,16 @@ /** * @package Updates */ -class Piwik_Updates_0_5_4 implements Piwik_iUpdate +class Piwik_Updates_0_5_4 extends Piwik_Updates { + static function getSql() + { + return array( + 'ALTER TABLE `'. Piwik::prefixTable('log_action') .'` + CHANGE `name` `name` TEXT' => false, + ); + } + static function update() { $config = Zend_Registry::get('config'); @@ -62,10 +70,6 @@ class Piwik_Updates_0_5_4 implements Piwik_iUpdate } } - Piwik_Updater::updateDatabase(__FILE__, array( - 'ALTER TABLE `'. Piwik::prefixTable('log_action') .'` - CHANGE `name` `name` TEXT' => false, - )); - + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.5.5.php b/core/Updates/0.5.5.php index 1aa88c27e0..538c85fb25 100644 --- a/core/Updates/0.5.5.php +++ b/core/Updates/0.5.5.php @@ -13,14 +13,31 @@ /** * @package Updates */ -class Piwik_Updates_0_5_5 implements Piwik_iUpdate +class Piwik_Updates_0_5_5 extends Piwik_Updates { - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + $sqlarray = array( 'DROP INDEX index_idsite_date ON ' . Piwik::prefixTable('log_visit') => '1091', 'CREATE INDEX index_idsite_date_config ON ' . Piwik::prefixTable('log_visit') . ' (idsite, visit_server_date, config_md5config(8))' => '1061', - )); + ); + + $tables = Piwik::getTablesInstalled(); + foreach($tables as $tableName) + { + if(preg_match('/archive_/', $tableName) == 1) + { + $sqlarray[ 'DROP INDEX index_all ON '. $tableName ] = '1091'; + $sqlarray[ 'CREATE INDEX index_idsite_dates_period ON '. $tableName .' (idsite, date1, date2, period)' ] = '1061'; + } + } + + return $sqlarray; + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } diff --git a/core/Updates/0.5.php b/core/Updates/0.5.php index 354c3e269c..5b4857c102 100644 --- a/core/Updates/0.5.php +++ b/core/Updates/0.5.php @@ -13,11 +13,11 @@ /** * @package Updates */ -class Piwik_Updates_0_5 implements Piwik_iUpdate +class Piwik_Updates_0_5 extends Piwik_Updates { - static function update() + static function getSql() { - Piwik_Updater::updateDatabase(__FILE__, array( + return array( 'ALTER TABLE ' . Piwik::prefixTable('log_action') . ' ADD COLUMN `hash` INTEGER(10) UNSIGNED NOT NULL AFTER `name`;' => '1060', 'ALTER TABLE ' . Piwik::prefixTable('log_visit') . ' CHANGE visit_exit_idaction visit_exit_idaction_url INTEGER(11) NOT NULL;' => '1054', 'ALTER TABLE ' . Piwik::prefixTable('log_visit') . ' CHANGE visit_entry_idaction visit_entry_idaction_url INTEGER(11) NOT NULL;' => '1054', @@ -28,6 +28,11 @@ class Piwik_Updates_0_5 implements Piwik_iUpdate 'UPDATE ' . Piwik::prefixTable('log_action') . ' SET `hash` = CRC32(name);' => false, 'CREATE INDEX index_type_hash ON ' . Piwik::prefixTable('log_action') . ' (type, hash);' => '1061', 'DROP INDEX index_type_name ON ' . Piwik::prefixTable('log_action') . ';' => '1091', - )); + ); + } + + static function update() + { + Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } } |