Improved caching system.
[com.zyxware.civiwci.git] / CRM / Wci / Upgrader.php
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"');
37 } // */
38
39 /**
40 * Example: Run a couple simple queries
41 *
42 * @return TRUE on success
43 * @throws Exception
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
60 return TRUE;
61 }
62
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 ;
72 ');
73 return TRUE;
74 }
75
76 }