From ae48345c1575339c44288d5e10f05fddfbf98fa2 Mon Sep 17 00:00:00 2001 From: Vimal Joseph Date: Mon, 17 Nov 2014 18:44:01 +0530 Subject: [PATCH] Enabled upgrader and set the latest changes to it. All changes to the db structure should be added as a new upgrade function. When adding a new version, execute the upgrades through the web interface by visiting the 'Manage Extensions' screen. This screen will display an alert with an action-link to perform the upgrades --- CRM/Wci/Upgrader.php | 25 ++++++++++++++++++------- CRM/Wci/Upgrader/Base.php | 2 +- wci.civix.php | 11 ++++++----- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/CRM/Wci/Upgrader.php b/CRM/Wci/Upgrader.php index a0afc6b..f6781fd 100644 --- a/CRM/Wci/Upgrader.php +++ b/CRM/Wci/Upgrader.php @@ -34,20 +34,31 @@ class CRM_Wci_Upgrader extends CRM_Wci_Upgrader_Base { * public function disable() { CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 0 WHERE bar = "whiz"'); - } + } // */ /** * Example: Run a couple simple queries * * @return TRUE on success * @throws Exception - * - public function upgrade_4200() { - $this->ctx->log->info('Applying update 4200'); - CRM_Core_DAO::executeQuery('UPDATE foo SET bar = "whiz"'); - CRM_Core_DAO::executeQuery('DELETE FROM bang WHERE willy = wonka(2)'); + */ + public function upgrade_1000() { + $this->ctx->log->info('Applying update 1000'); + CRM_Core_DAO::executeQuery(' + ALTER TABLE `civicrm_wci_widget` + ADD `show_pb_perc` TINYINT(4) NOT NULL DEFAULT "1" + COMMENT "show pb in percentage or amount" + AFTER `hide_pbcap` + '); + CRM_Core_DAO::executeQuery(' + ALTER TABLE `civicrm_wci_widget` + ADD `color_progress_bar_bg` VARCHAR(10) COLLATE utf8_unicode_ci NOT NULL + COMMENT "Progress bar background color." + AFTER `color_progress_bar` + '); + return TRUE; - } // */ + } /** diff --git a/CRM/Wci/Upgrader/Base.php b/CRM/Wci/Upgrader/Base.php index fa1544b..7309db6 100644 --- a/CRM/Wci/Upgrader/Base.php +++ b/CRM/Wci/Upgrader/Base.php @@ -39,7 +39,7 @@ class CRM_Wci_Upgrader_Base { if (! self::$instance) { // FIXME auto-generate self::$instance = new CRM_Wci_Upgrader( - 'civicrm-wci', + 'org.civicrm.wci', realpath(__DIR__ .'/../../../') ); } diff --git a/wci.civix.php b/wci.civix.php index 86eba52..ae56ebc 100644 --- a/wci.civix.php +++ b/wci.civix.php @@ -47,7 +47,7 @@ function _wci_civix_civicrm_xmlMenu(&$files) { function _wci_civix_civicrm_install() { _wci_civix_civicrm_config(); if ($upgrader = _wci_civix_upgrader()) { - return $upgrader->onInstall(); + $upgrader->onInstall(); } } @@ -59,7 +59,7 @@ function _wci_civix_civicrm_install() { function _wci_civix_civicrm_uninstall() { _wci_civix_civicrm_config(); if ($upgrader = _wci_civix_upgrader()) { - return $upgrader->onUninstall(); + $upgrader->onUninstall(); } } @@ -72,7 +72,7 @@ function _wci_civix_civicrm_enable() { _wci_civix_civicrm_config(); if ($upgrader = _wci_civix_upgrader()) { if (is_callable(array($upgrader, 'onEnable'))) { - return $upgrader->onEnable(); + $upgrader->onEnable(); } } } @@ -81,12 +81,13 @@ function _wci_civix_civicrm_enable() { * (Delegated) Implementation of hook_civicrm_disable * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable + * @return mixed */ function _wci_civix_civicrm_disable() { _wci_civix_civicrm_config(); if ($upgrader = _wci_civix_upgrader()) { if (is_callable(array($upgrader, 'onDisable'))) { - return $upgrader->onDisable(); + $upgrader->onDisable(); } } } @@ -275,4 +276,4 @@ function _wci_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) { if(is_dir($settingsDir) && !in_array($settingsDir, $metaDataFolders)) { $metaDataFolders[] = $settingsDir; } -} \ No newline at end of file +} -- 2.25.1