Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
// $Id$
/**
* Implementation of hook_schema().
*/
function data_schema() {
$schema['data_tables'] = array(
'description' => 'Tables managed by Data module.',
'fields' => array(
'title' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
'description' => 'Natural name of the table.',
),
'name' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
'description' => 'Table name.',
),
'table_schema' => array(
'type' => 'text',
'not null' => FALSE,
'description' => 'Table schema.',
'serialize' => TRUE,
),
'meta' => array(
'type' => 'text',
'not null' => FALSE,
'description' => 'Meta information about the table and its fields.',
'serialize' => TRUE,
),
),
'indexes' => array(
'name' => array('name'),
),
);
$schema['data_join'] = array(
'description' => 'Join information for tables managed Data module.',
'fields' => array(
'left_table' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
'description' => 'Left table.',
),
'left_field' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
'description' => 'Column of left table.',
),
'right_table' => array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
'default' => '',
'description' => 'Right table.',
),
'right_field' => array( // @todo: should be right_field
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
'default' => '',
'description' => 'Column of right table.',
),
'inner_join' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => t('Flag indicating whether this relation should use an INNER JOIN.'),
),
),
'primary key' => array(
'left_table',
'right_table',
),
'indexes' => array(
'left_table' => array('left_table'),
'right_table' => array('right_table'),
),
);
// Load dynamically created tables.
if (function_exists('data_get_schema')) {
$schema += data_get_schema();
}
return $schema;
}
/**
* Implementation of hook_install().
*/
function data_install() {
// Create tables.
drupal_install_schema('data');
}
/**
* Implementation of hook_uninstall().
*/
function data_uninstall() {
// Remove tables.
drupal_uninstall_schema('data');
}