-
Notifications
You must be signed in to change notification settings - Fork 13
/
open_data_schema_map.install
141 lines (133 loc) · 3.73 KB
/
open_data_schema_map.install
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* @file
* Schemas for schemas, open data style.
*/
/**
* Implements hook_schema().
*/
function open_data_schema_map_schema() {
$schema['open_data_schema_map'] = array(
'description' => 'Stores open data schema mappings',
'fields' => array(
'id' => array(
'description' => 'The primary identifier for an api.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => 'The displayed name for an api.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
),
'enabled' => array(
'description' => 'Whether API is enabled.',
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'default' => 0,
),
'machine_name' => array(
'description' => 'The machine name for an api.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
),
'api_schema' => array(
'description' => 'The schema for an api.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
),
'description' => array(
'description' => 'The displayed description for an api.',
'type' => 'text',
'not null' => FALSE,
),
'type' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'description' => 'The name of the entity type a mapping applies to (node, user, comment, etc.).',
),
'bundle' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'description' => 'The name of the bundle a mapping applies to.',
),
'mapping' => array(
'description' => 'The serialized mapping of the schema to fields.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
),
'outputformat' => array(
'description' => 'Output Format.',
'type' => 'varchar',
'length' => 20,
'not null' => TRUE,
'default' => 'json',
),
'endpoint' => array(
'type' => 'varchar',
'length' => 256,
'not null' => TRUE,
'description' => 'The name of the endpoint for the new API.',
),
'arguments' => array(
'description' => 'The serialized mapping of the arguments to fields.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
),
'filter_enabled' => array(
'description' => 'Whether Data Federation Filter is enabled.',
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'default' => 0,
),
),
'primary key' => array('id'),
);
return $schema;
}
/**
* Ensures that the output format field is in the table.
*
* Also sets outputformat to 'json' for all existing entries
*/
function open_data_schema_map_update_7001() {
$column = array(
'type' => 'varchar',
'description' => "Output Format",
'length' => 20,
'not null' => TRUE,
'default' => 'json',
);
$data_table_name = 'open_data_schema_map';
if (!db_field_exists('open_data_schema_map', 'outputformat')) {
db_add_field($data_table_name, 'outputformat', $column);
}
}
/**
* Ensures that the filter_enabled field is in the table.
*/
function open_data_schema_map_update_7002() {
$column = array(
'description' => 'Whether Data Federation Filter is enabled.',
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'default' => 0,
);
$data_table_name = 'open_data_schema_map';
if (!db_field_exists('open_data_schema_map', 'filter_enabled')) {
db_add_field($data_table_name, 'filter_enabled', $column);
}
}