4 * Collection of upgrade steps
6 class CRM_Wci_Upgrader
extends CRM_Wci_Upgrader_Base
{
8 // By convention, functions that look like "function upgrade_NNNN()" are
9 // upgrade tasks. They are executed in order (like Drupal's hook_update_N).
12 * Example: Run an external SQL script when the module is installed
14 public function install() {
15 $this->executeSqlFile('sql/install.sql');
19 * Example: Run an external SQL script when the module is uninstalled
21 public function uninstall() {
22 $this->executeSqlFile('sql/uninstall.sql');
26 * Example: Run a simple query when a module is enabled
28 public function enable() {
29 CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 1 WHERE bar = "whiz"');
33 * Example: Run a simple query when a module is disabled
35 public function disable() {
36 CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 0 WHERE bar = "whiz"');
40 * Example: Run a couple simple queries
42 * @return TRUE on success
45 public function upgrade_1000() {
46 $this->ctx
->log
->info('Applying update 1000');
47 CRM_Core_DAO
::executeQuery('
48 ALTER TABLE `civicrm_wci_widget`
49 ADD `show_pb_perc` TINYINT(4) NOT NULL DEFAULT "1"
50 COMMENT "show pb in percentage or amount"
53 CRM_Core_DAO
::executeQuery('
54 ALTER TABLE `civicrm_wci_widget`
55 ADD `color_progress_bar_bg` VARCHAR(10) COLLATE utf8_unicode_ci NOT NULL
56 COMMENT "Progress bar background color."
57 AFTER `color_progress_bar`
63 public function upgrade_1001() {
64 $this->ctx
->log
->info('Applying update 1001');
65 CRM_Core_DAO
::executeQuery('
66 CREATE TABLE IF NOT EXISTS `civicrm_wci_widget_cache` (
67 `widget_id` int(10) unsigned NOT NULL COMMENT "widget id.",
68 `widget_code` text DEFAULT NULL COMMENT "Widget code.",
69 `expire` int(10) DEFAULT 0 COMMENT "A Unix timestamp indicating when the cache entry should expire.",
70 PRIMARY KEY (`widget_id`)
71 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;