/[drupal]/contributions/modules/metrics/metrics.install
ViewVC logotype

Contents of /contributions/modules/metrics/metrics.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Jul 24 21:11:02 2007 UTC (2 years, 4 months ago) by drewish
Branch: MAIN
CVS Tags: DRUPAL-5--0-0-SOC_FINAL, HEAD
File MIME type: text/x-php
Inital import from my sandbox (contributions/sandbox/drewish/project_metrics)
1 <?php
2 // $Id: metrics.install,v 1.2 2007/07/11 22:03:47 drewish Exp $
3
4 /**
5 * Implementation of hook_install().
6 */
7 function metrics_install() {
8 switch ($GLOBALS['db_type']) {
9 case 'mysql':
10 case 'mysqli':
11 db_query("CREATE TABLE {metrics_property} (
12 property_id int unsigned NOT NULL auto_increment,
13 name varchar(255) NOT NULL default '',
14 description text NOT NULL,
15 PRIMARY KEY (property_id)
16 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
17
18 db_query("CREATE TABLE {metrics_property_node_types} (
19 property_id int unsigned NOT NULL DEFAULT '0',
20 type varchar(32) NOT NULL DEFAULT '',
21 PRIMARY KEY (property_id, type)
22 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
23
24 db_query("CREATE TABLE {metrics_property_result} (
25 property_id int NOT NULL default '0',
26 nid int NOT NULL default '0',
27 ranking_id int unsigned NOT NULL DEFAULT '0',
28 value int NOT NULL default '0',
29 description text NOT NULL,
30 timestamp int NOT NULL default '0',
31 PRIMARY KEY (property_id, nid),
32 KEY metrics_ranking_timestamp (timestamp),
33 KEY metrics_ranking_value (value)
34 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
35
36 db_query("CREATE TABLE {metrics_metric} (
37 metric_id int unsigned NOT NULL auto_increment,
38 property_id int unsigned NOT NULL DEFAULT '0',
39 function_name varchar(255) NOT NULL default '',
40 options text NOT NULL,
41 displayed int default '0',
42 multiplier float default '1.0',
43 PRIMARY KEY (metric_id)
44 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
45
46 // It seems like it might be a good idea to cache the results of each
47 // individual metric, and then use those when computing the rows in
48 // {metrics_property_result}.
49 # db_query("CREATE TABLE {metrics_metric_result} (
50 # property_id int NOT NULL default '0',
51 # nid int NOT NULL default '0',
52 # ranking_id int unsigned NOT NULL DEFAULT '0',
53 # value int NOT NULL default '0',
54 # description text NOT NULL,
55 # timestamp int NOT NULL default '0',
56 # PRIMARY KEY (property_id, nid),
57 # KEY metrics_ranking_timestamp (timestamp),
58 # KEY metrics_ranking_value (value)
59 # ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
60
61 db_query("CREATE TABLE {metrics_ranking} (
62 ranking_id int unsigned NOT NULL auto_increment,
63 property_id int NOT NULL default '0',
64 name varchar(255) NOT NULL default '',
65 threshold int NOT NULL default '0',
66 description text NOT NULL,
67 PRIMARY KEY (ranking_id)
68 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
69
70 break;
71 case 'pgsql':
72 break;
73 }
74 }
75
76 /**
77 * Implementation of hook_uninstall().
78 */
79 function metrics_uninstall() {
80 db_query('DROP TABLE {metrics_property}');
81 db_query('DROP TABLE {metrics_property_node_types}');
82 db_query('DROP TABLE {metrics_property_result}');
83 db_query('DROP TABLE {metrics_metric}');
84 db_query('DROP TABLE {metrics_ranking}');
85 /*
86 variable_del('metrics_');
87 */
88 }

  ViewVC Help
Powered by ViewVC 1.1.2