-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgovinfo.install
218 lines (211 loc) · 4.97 KB
/
govinfo.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
use Drupal\Core\Database\Database;
/**
* Implements hook_schema().
*/
function govinfo_schema() {
$schema = [];
/**
* A table of the base collection data. This does not need to be an entity, so we
* will keep it simply in a table for reference.
*/
$schema['govinfo_collections'] = [
'fields' => [
'code' => [
'type' => 'varchar',
'length' => 16,
'not null' => TRUE,
'default' => '',
],
'name' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'package_count' => [
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'granule_count' => [
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'last_indexed' => [
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
],
'primary key' => ['code'],
];
/**
* We need a schema to track package updates. If we have package updates, then
* we need to re-index the granules. If not, we can skip them and save API calls.
* This index provides a last updated. When we load packages we can compare the
* last updated of that call with what is in the database and any differences
* can fire off a re-index.
*/
$schema['govinfo_collection_meta'] = [
'fields' => [
'cid' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'collection_code' => [
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
],
'package_id' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'last_modified' => [
'type' => 'int',
'unsigned' => FALSE,
'not null' => TRUE,
'default' => 0,
],
'package_link' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'last_modified' => [
'type' => 'int',
'unsigned' => FALSE,
'not null' => TRUE,
'default' => 0,
],
'doc_class' => [
'type' => 'varchar',
'length' => 24,
'not null' => TRUE,
'default' => '',
],
'title' => [
'type' => 'text',
'size' => 'medium',
'not null' => FALSE,
],
'congress' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'date_issued' => [
'type' => 'int',
'unsigned' => FALSE,
'not null' => TRUE,
'default' => 0,
],
],
'primary key' => ['cid'],
'indexes' => [
'doc_class' => ['doc_class'],
'congress' => ['congress'],
'package_id' => ['package_id']
],
];
$schema['govinfo_granules_meta'] = [
'fields' => [
'gid' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'package_id' => [
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
],
'title' => [
'type' => 'text',
'size' => 'medium',
'not null' => FALSE,
],
'granule_id' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
'granule_link' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
'granule_class' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
],
'primary key' => ['gid'],
'indexes' => [
'package_id' => ['package_id'],
'granule_class' => ['granule_class']
],
];
$schema['govinfo_document_queue'] = [
'fields' => [
'did' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'category' => [
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
],
'date_issued' => [
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
],
'document_type' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
'summary_id' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
'granule_id' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
'document_link' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
],
'primary key' => ['did'],
'indexes' => [
'category' => ['category'],
'document_type' => ['document_type'],
'summary_id' => ['summary_id'],
],
];
return $schema;
}