1
|
<?php
|
2
|
// $Id$
|
3
|
|
4
|
/**
|
5
|
* Implementation of hook_install().
|
6
|
*/
|
7
|
function cdm_api_install(){
|
8
|
|
9
|
db_query("CREATE TABLE {cache_cdm_ws} (
|
10
|
cid varchar(255) NOT NULL default '', -- max key length in some cases is only 767 byte ~ varchar(255)
|
11
|
data longblob,
|
12
|
expire int NOT NULL default '0',
|
13
|
created int NOT NULL default '0',
|
14
|
headers text,
|
15
|
PRIMARY KEY (cid),
|
16
|
INDEX expire (expire)
|
17
|
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
|
18
|
|
19
|
db_query(_get_sql_create_nodecdm());
|
20
|
db_query(_get_sql_fix_watchdog());
|
21
|
}
|
22
|
|
23
|
/**
|
24
|
* Implementation of hook_uninstall().
|
25
|
*/
|
26
|
function cdm_api_uninstall(){
|
27
|
db_query("DROP TABLE {cache_cdm_ws};");
|
28
|
db_query("DROP TABLE {node_cdm};");
|
29
|
// according nodes are deleted by cdm_dataportal_uninstall
|
30
|
|
31
|
}
|
32
|
|
33
|
/**
|
34
|
* Implementation of hook_api_update_N().
|
35
|
*
|
36
|
* Database updates consist of 3 parts:
|
37
|
* 1 digit for Drupal core compatibility
|
38
|
* 1 digit for your module's major release version (e.g. is this the 5.x-1.* (1) or 5.x-2.* (2) series of your module?)
|
39
|
* 2 digits for sequential counting starting with 00
|
40
|
* The 2nd digit should be 0 for initial porting of your module to a new Drupal core API.
|
41
|
*
|
42
|
* Update 1 for version 5.x-1.*
|
43
|
*/
|
44
|
function cdm_api_update_5101() {
|
45
|
$items = array();
|
46
|
$items[] = update_sql(_get_sql_create_nodecdm());
|
47
|
$items[] = update_sql(_get_sql_fix_watchdog());
|
48
|
return $items;
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* Implementation of hook_api_update_N().
|
53
|
*
|
54
|
* Database updates consist of 3 parts:
|
55
|
* 1 digit for Drupal core compatibility
|
56
|
* 1 digit for your module's major release version (e.g. is this the 5.x-1.* (1) or 5.x-2.* (2) series of your module?)
|
57
|
* 2 digits for sequential counting starting with 00
|
58
|
* The 2nd digit should be 0 for initial porting of your module to a new Drupal core API.
|
59
|
*
|
60
|
* Update 1 for version 5.x-1.*
|
61
|
*/
|
62
|
function cdm_api_update_5102() {
|
63
|
$items = array();
|
64
|
$items[] = update_sql('ALTER TABLE {node_cdm} add `hash` char(32) default NULL AFTER `wsuri`;');
|
65
|
$items[] = update_sql('UPDATE {node_cdm} SET `hash`= MD5(CONCAT(`wsuri`, `uuid`));');
|
66
|
$items[] = update_sql('ALTER TABLE {node_cdm} CHANGE COLUMN `hash` `hash` CHAR(32) NOT NULL AFTER `wsuri`;');
|
67
|
$items[] = update_sql('ALTER TABLE {node_cdm} DROP PRIMARY KEY;');
|
68
|
$items[] = update_sql('ALTER TABLE {node_cdm} ADD PRIMARY KEY (`hash`);');
|
69
|
return $items;
|
70
|
}
|
71
|
|
72
|
// ------------------------- SQL Scripts ------------------------ //
|
73
|
|
74
|
function _get_sql_create_nodecdm() {
|
75
|
return "
|
76
|
CREATE TABLE {node_cdm} (
|
77
|
`nid` int(11) NOT NULL,
|
78
|
`wsuri` varchar(255) default NULL,
|
79
|
`hash` char(32) NOT NULL,
|
80
|
`cdmtype` varchar(255) default NULL,
|
81
|
`uuid` varchar(255) default NULL,
|
82
|
PRIMARY KEY (`hash`)
|
83
|
) /*!40100 DEFAULT CHARACTER SET UTF8 */
|
84
|
";
|
85
|
}
|
86
|
|
87
|
function _get_sql_fix_watchdog() {
|
88
|
return "ALTER TABLE {watchdog} CHANGE referer referer TEXT NOT NULL ;";
|
89
|
}
|