Commit | Line | Data |
---|---|---|
60488185 M |
1 | <?php |
2 | ||
3 | /** | |
4 | * Collection of upgrade steps | |
5 | */ | |
6 | class CRM_Wci_Upgrader extends CRM_Wci_Upgrader_Base { | |
7 | ||
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). | |
10 | ||
11 | /** | |
12 | * Example: Run an external SQL script when the module is installed | |
13 | */ | |
14 | public function install() { | |
15 | $this->executeSqlFile('sql/install.sql'); | |
16 | } | |
17 | ||
18 | /** | |
19 | * Example: Run an external SQL script when the module is uninstalled | |
20 | */ | |
21 | public function uninstall() { | |
22 | $this->executeSqlFile('sql/uninstall.sql'); | |
23 | } | |
24 | ||
25 | /** | |
26 | * Example: Run a simple query when a module is enabled | |
27 | * | |
28 | public function enable() { | |
29 | CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 1 WHERE bar = "whiz"'); | |
30 | } | |
31 | ||
32 | /** | |
33 | * Example: Run a simple query when a module is disabled | |
34 | * | |
35 | public function disable() { | |
36 | CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 0 WHERE bar = "whiz"'); | |
ae48345c | 37 | } // */ |
60488185 M |
38 | |
39 | /** | |
40 | * Example: Run a couple simple queries | |
41 | * | |
42 | * @return TRUE on success | |
43 | * @throws Exception | |
ae48345c VJ |
44 | */ |
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" | |
51 | AFTER `hide_pbcap` | |
52 | '); | |
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` | |
58 | '); | |
59 | ||
60488185 | 60 | return TRUE; |
ae48345c | 61 | } |
60488185 | 62 | |
1008246f J |
63 | public function upgrade_1001() { |
64 | $this->ctx->log->info('Applying update 1001'); | |
65 | CRM_Core_DAO::executeQuery(' | |
3ebd2f4b VJ |
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.", | |
96beafc6 | 70 | `createdtime` int(10) DEFAULT 0 COMMENT "A Unix timestamp indicating create time.", |
3ebd2f4b | 71 | PRIMARY KEY (`widget_id`) |
1008246f J |
72 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; |
73 | '); | |
74 | return TRUE; | |
75 | } | |
60488185 | 76 | |
60488185 | 77 | } |