1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Implementation of hook_schema(). |
---|
5 | */ |
---|
6 | function node_schema() { |
---|
7 | $schema['node'] = array( |
---|
8 | 'description' => 'The base table for nodes.', |
---|
9 | 'fields' => array( |
---|
10 | 'nid' => array( |
---|
11 | 'description' => 'The primary identifier for a node.', |
---|
12 | 'type' => 'serial', |
---|
13 | 'unsigned' => TRUE, |
---|
14 | 'not null' => TRUE), |
---|
15 | 'vid' => array( |
---|
16 | 'description' => 'The current {node_revisions}.vid version identifier.', |
---|
17 | 'type' => 'int', |
---|
18 | 'unsigned' => TRUE, |
---|
19 | 'not null' => TRUE, |
---|
20 | 'default' => 0), |
---|
21 | 'type' => array( |
---|
22 | 'description' => 'The {node_type}.type of this node.', |
---|
23 | 'type' => 'varchar', |
---|
24 | 'length' => 32, |
---|
25 | 'not null' => TRUE, |
---|
26 | 'default' => ''), |
---|
27 | 'language' => array( |
---|
28 | 'description' => 'The {languages}.language of this node.', |
---|
29 | 'type' => 'varchar', |
---|
30 | 'length' => 12, |
---|
31 | 'not null' => TRUE, |
---|
32 | 'default' => ''), |
---|
33 | 'title' => array( |
---|
34 | 'description' => 'The title of this node, always treated as non-markup plain text.', |
---|
35 | 'type' => 'varchar', |
---|
36 | 'length' => 255, |
---|
37 | 'not null' => TRUE, |
---|
38 | 'default' => ''), |
---|
39 | 'uid' => array( |
---|
40 | 'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.', |
---|
41 | 'type' => 'int', |
---|
42 | 'not null' => TRUE, |
---|
43 | 'default' => 0), |
---|
44 | 'status' => array( |
---|
45 | 'description' => 'Boolean indicating whether the node is published (visible to non-administrators).', |
---|
46 | 'type' => 'int', |
---|
47 | 'not null' => TRUE, |
---|
48 | 'default' => 1), |
---|
49 | 'created' => array( |
---|
50 | 'description' => 'The Unix timestamp when the node was created.', |
---|
51 | 'type' => 'int', |
---|
52 | 'not null' => TRUE, |
---|
53 | 'default' => 0), |
---|
54 | 'changed' => array( |
---|
55 | 'description' => 'The Unix timestamp when the node was most recently saved.', |
---|
56 | 'type' => 'int', |
---|
57 | 'not null' => TRUE, |
---|
58 | 'default' => 0), |
---|
59 | 'comment' => array( |
---|
60 | 'description' => 'Whether comments are allowed on this node: 0 = no, 1 = read only, 2 = read/write.', |
---|
61 | 'type' => 'int', |
---|
62 | 'not null' => TRUE, |
---|
63 | 'default' => 0), |
---|
64 | 'promote' => array( |
---|
65 | 'description' => 'Boolean indicating whether the node should be displayed on the front page.', |
---|
66 | 'type' => 'int', |
---|
67 | 'not null' => TRUE, |
---|
68 | 'default' => 0), |
---|
69 | 'moderate' => array( |
---|
70 | 'description' => 'Previously, a boolean indicating whether the node was "in moderation"; mostly no longer used.', |
---|
71 | 'type' => 'int', |
---|
72 | 'not null' => TRUE, |
---|
73 | 'default' => 0), |
---|
74 | 'sticky' => array( |
---|
75 | 'description' => 'Boolean indicating whether the node should be displayed at the top of lists in which it appears.', |
---|
76 | 'type' => 'int', |
---|
77 | 'not null' => TRUE, |
---|
78 | 'default' => 0), |
---|
79 | 'tnid' => array( |
---|
80 | 'description' => 'The translation set id for this node, which equals the node id of the source post in each set.', |
---|
81 | 'type' => 'int', |
---|
82 | 'unsigned' => TRUE, |
---|
83 | 'not null' => TRUE, |
---|
84 | 'default' => 0), |
---|
85 | 'translate' => array( |
---|
86 | 'description' => 'A boolean indicating whether this translation page needs to be updated.', |
---|
87 | 'type' => 'int', |
---|
88 | 'not null' => TRUE, |
---|
89 | 'default' => 0), |
---|
90 | ), |
---|
91 | 'indexes' => array( |
---|
92 | 'node_changed' => array('changed'), |
---|
93 | 'node_created' => array('created'), |
---|
94 | 'node_moderate' => array('moderate'), |
---|
95 | 'node_promote_status' => array('promote', 'status'), |
---|
96 | 'node_status_type' => array('status', 'type', 'nid'), |
---|
97 | 'node_title_type' => array('title', array('type', 4)), |
---|
98 | 'node_type' => array(array('type', 4)), |
---|
99 | 'uid' => array('uid'), |
---|
100 | 'tnid' => array('tnid'), |
---|
101 | 'translate' => array('translate'), |
---|
102 | ), |
---|
103 | 'unique keys' => array( |
---|
104 | 'vid' => array('vid') |
---|
105 | ), |
---|
106 | 'primary key' => array('nid'), |
---|
107 | ); |
---|
108 | |
---|
109 | $schema['node_access'] = array( |
---|
110 | 'description' => 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.', |
---|
111 | 'fields' => array( |
---|
112 | 'nid' => array( |
---|
113 | 'description' => 'The {node}.nid this record affects.', |
---|
114 | 'type' => 'int', |
---|
115 | 'unsigned' => TRUE, |
---|
116 | 'not null' => TRUE, |
---|
117 | 'default' => 0), |
---|
118 | 'gid' => array( |
---|
119 | 'description' => "The grant ID a user must possess in the specified realm to gain this row's privileges on the node.", |
---|
120 | 'type' => 'int', |
---|
121 | 'unsigned' => TRUE, |
---|
122 | 'not null' => TRUE, |
---|
123 | 'default' => 0), |
---|
124 | 'realm' => array( |
---|
125 | 'description' => 'The realm in which the user must possess the grant ID. Each node access node can define one or more realms.', |
---|
126 | 'type' => 'varchar', |
---|
127 | 'length' => 255, |
---|
128 | 'not null' => TRUE, |
---|
129 | 'default' => ''), |
---|
130 | 'grant_view' => array( |
---|
131 | 'description' => 'Boolean indicating whether a user with the realm/grant pair can view this node.', |
---|
132 | 'type' => 'int', |
---|
133 | 'unsigned' => TRUE, |
---|
134 | 'not null' => TRUE, |
---|
135 | 'default' => 0, |
---|
136 | 'size' => 'tiny'), |
---|
137 | 'grant_update' => array( |
---|
138 | 'description' => 'Boolean indicating whether a user with the realm/grant pair can edit this node.', |
---|
139 | 'type' => 'int', |
---|
140 | 'unsigned' => TRUE, |
---|
141 | 'not null' => TRUE, |
---|
142 | 'default' => 0, |
---|
143 | 'size' => 'tiny'), |
---|
144 | 'grant_delete' => array( |
---|
145 | 'description' => 'Boolean indicating whether a user with the realm/grant pair can delete this node.', |
---|
146 | 'type' => 'int', |
---|
147 | 'unsigned' => TRUE, |
---|
148 | 'not null' => TRUE, |
---|
149 | 'default' => 0, |
---|
150 | 'size' => 'tiny') |
---|
151 | ), |
---|
152 | 'primary key' => array('nid', 'gid', 'realm'), |
---|
153 | ); |
---|
154 | |
---|
155 | $schema['node_counter'] = array( |
---|
156 | 'description' => 'Access statistics for {node}s.', |
---|
157 | 'fields' => array( |
---|
158 | 'nid' => array( |
---|
159 | 'description' => 'The {node}.nid for these statistics.', |
---|
160 | 'type' => 'int', |
---|
161 | 'not null' => TRUE, |
---|
162 | 'default' => 0), |
---|
163 | 'totalcount' => array( |
---|
164 | 'description' => 'The total number of times the {node} has been viewed.', |
---|
165 | 'type' => 'int', |
---|
166 | 'unsigned' => TRUE, |
---|
167 | 'not null' => TRUE, |
---|
168 | 'default' => 0, |
---|
169 | 'size' => 'big'), |
---|
170 | 'daycount' => array( |
---|
171 | 'description' => 'The total number of times the {node} has been viewed today.', |
---|
172 | 'type' => 'int', |
---|
173 | 'unsigned' => TRUE, |
---|
174 | 'not null' => TRUE, |
---|
175 | 'default' => 0, |
---|
176 | 'size' => 'medium'), |
---|
177 | 'timestamp' => array( |
---|
178 | 'description' => 'The most recent time the {node} has been viewed.', |
---|
179 | 'type' => 'int', |
---|
180 | 'unsigned' => TRUE, |
---|
181 | 'not null' => TRUE, |
---|
182 | 'default' => 0) |
---|
183 | ), |
---|
184 | 'primary key' => array('nid'), |
---|
185 | ); |
---|
186 | |
---|
187 | $schema['node_revisions'] = array( |
---|
188 | 'description' => 'Stores information about each saved version of a {node}.', |
---|
189 | 'fields' => array( |
---|
190 | 'nid' => array( |
---|
191 | 'description' => 'The {node} this version belongs to.', |
---|
192 | 'type' => 'int', |
---|
193 | 'unsigned' => TRUE, |
---|
194 | 'not null' => TRUE, |
---|
195 | 'default' => 0), |
---|
196 | 'vid' => array( |
---|
197 | 'description' => 'The primary identifier for this version.', |
---|
198 | 'type' => 'serial', |
---|
199 | 'unsigned' => TRUE, |
---|
200 | 'not null' => TRUE), |
---|
201 | 'uid' => array( |
---|
202 | 'description' => 'The {users}.uid that created this version.', |
---|
203 | 'type' => 'int', |
---|
204 | 'not null' => TRUE, |
---|
205 | 'default' => 0), |
---|
206 | 'title' => array( |
---|
207 | 'description' => 'The title of this version.', |
---|
208 | 'type' => 'varchar', |
---|
209 | 'length' => 255, |
---|
210 | 'not null' => TRUE, |
---|
211 | 'default' => ''), |
---|
212 | 'body' => array( |
---|
213 | 'description' => 'The body of this version.', |
---|
214 | 'type' => 'text', |
---|
215 | 'not null' => TRUE, |
---|
216 | 'size' => 'big'), |
---|
217 | 'teaser' => array( |
---|
218 | 'description' => 'The teaser of this version.', |
---|
219 | 'type' => 'text', |
---|
220 | 'not null' => TRUE, |
---|
221 | 'size' => 'big'), |
---|
222 | 'log' => array( |
---|
223 | 'description' => 'The log entry explaining the changes in this version.', |
---|
224 | 'type' => 'text', |
---|
225 | 'not null' => TRUE, |
---|
226 | 'size' => 'big'), |
---|
227 | 'timestamp' => array( |
---|
228 | 'description' => 'A Unix timestamp indicating when this version was created.', |
---|
229 | 'type' => 'int', |
---|
230 | 'not null' => TRUE, |
---|
231 | 'default' => 0), |
---|
232 | 'format' => array( |
---|
233 | 'description' => "The input format used by this version's body.", |
---|
234 | 'type' => 'int', |
---|
235 | 'not null' => TRUE, |
---|
236 | 'default' => 0) |
---|
237 | ), |
---|
238 | 'indexes' => array( |
---|
239 | 'nid' => array('nid'), |
---|
240 | 'uid' => array('uid') |
---|
241 | ), |
---|
242 | 'primary key' => array('vid'), |
---|
243 | ); |
---|
244 | |
---|
245 | $schema['node_type'] = array( |
---|
246 | 'description' => 'Stores information about all defined {node} types.', |
---|
247 | 'fields' => array( |
---|
248 | 'type' => array( |
---|
249 | 'description' => 'The machine-readable name of this type.', |
---|
250 | 'type' => 'varchar', |
---|
251 | 'length' => 32, |
---|
252 | 'not null' => TRUE), |
---|
253 | 'name' => array( |
---|
254 | 'description' => 'The human-readable name of this type.', |
---|
255 | 'type' => 'varchar', |
---|
256 | 'length' => 255, |
---|
257 | 'not null' => TRUE, |
---|
258 | 'default' => ''), |
---|
259 | 'module' => array( |
---|
260 | 'description' => 'The base string used to construct callbacks corresponding to this node type.', |
---|
261 | 'type' => 'varchar', |
---|
262 | 'length' => 255, |
---|
263 | 'not null' => TRUE), |
---|
264 | 'description' => array( |
---|
265 | 'description' => 'A brief description of this type.', |
---|
266 | 'type' => 'text', |
---|
267 | 'not null' => TRUE, |
---|
268 | 'size' => 'medium'), |
---|
269 | 'help' => array( |
---|
270 | 'description' => 'Help information shown to the user when creating a {node} of this type.', |
---|
271 | 'type' => 'text', |
---|
272 | 'not null' => TRUE, |
---|
273 | 'size' => 'medium'), |
---|
274 | 'has_title' => array( |
---|
275 | 'description' => 'Boolean indicating whether this type uses the {node}.title field.', |
---|
276 | 'type' => 'int', |
---|
277 | 'unsigned' => TRUE, |
---|
278 | 'not null' => TRUE, |
---|
279 | 'size' => 'tiny'), |
---|
280 | 'title_label' => array( |
---|
281 | 'description' => 'The label displayed for the title field on the edit form.', |
---|
282 | 'type' => 'varchar', |
---|
283 | 'length' => 255, |
---|
284 | 'not null' => TRUE, |
---|
285 | 'default' => ''), |
---|
286 | 'has_body' => array( |
---|
287 | 'description' => 'Boolean indicating whether this type uses the {node_revisions}.body field.', |
---|
288 | 'type' => 'int', |
---|
289 | 'unsigned' => TRUE, |
---|
290 | 'not null' => TRUE, |
---|
291 | 'size' => 'tiny'), |
---|
292 | 'body_label' => array( |
---|
293 | 'description' => 'The label displayed for the body field on the edit form.', |
---|
294 | 'type' => 'varchar', |
---|
295 | 'length' => 255, |
---|
296 | 'not null' => TRUE, |
---|
297 | 'default' => ''), |
---|
298 | 'min_word_count' => array( |
---|
299 | 'description' => 'The minimum number of words the body must contain.', |
---|
300 | 'type' => 'int', |
---|
301 | 'unsigned' => TRUE, |
---|
302 | 'not null' => TRUE, |
---|
303 | 'size' => 'small'), |
---|
304 | 'custom' => array( |
---|
305 | 'description' => 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via a module like the Content Construction Kit (TRUE).', |
---|
306 | 'type' => 'int', |
---|
307 | 'not null' => TRUE, |
---|
308 | 'default' => 0, |
---|
309 | 'size' => 'tiny'), |
---|
310 | 'modified' => array( |
---|
311 | 'description' => 'A boolean indicating whether this type has been modified by an administrator; currently not used in any way.', |
---|
312 | 'type' => 'int', |
---|
313 | 'not null' => TRUE, |
---|
314 | 'default' => 0, |
---|
315 | 'size' => 'tiny'), |
---|
316 | 'locked' => array( |
---|
317 | 'description' => 'A boolean indicating whether the administrator can change the machine name of this type.', |
---|
318 | 'type' => 'int', |
---|
319 | 'not null' => TRUE, |
---|
320 | 'default' => 0, |
---|
321 | 'size' => 'tiny'), |
---|
322 | 'orig_type' => array( |
---|
323 | 'description' => 'The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.', |
---|
324 | 'type' => 'varchar', |
---|
325 | 'length' => 255, |
---|
326 | 'not null' => TRUE, |
---|
327 | 'default' => '') |
---|
328 | ), |
---|
329 | 'primary key' => array('type'), |
---|
330 | ); |
---|
331 | |
---|
332 | return $schema; |
---|
333 | } |
---|
334 | |
---|