node.install 12.3 KB
Newer Older
1
2
3
4
5
6
7
8
<?php
// $Id$

/**
 * Implementation of hook_schema().
 */
function node_schema() {
  $schema['node'] = array(
9
    'description' => t('The base table for nodes.'),
10
    'fields' => array(
11
12
13
14
      'nid' => array(
        'description' => t('The primary identifier for a node.'),
        'type' => 'serial',
        'unsigned' => TRUE,
15
16
        'not null' => TRUE,
      ),
17
18
19
20
21
      'vid' => array(
        'description' => t('The current {node_revisions}.vid version identifier.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
22
23
        'default' => 0,
      ),
24
      'type' => array(
25
        'description' => t('The {node_type}.type of this node.'),
26
27
28
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
29
30
        'default' => '',
      ),
31
32
33
34
35
      'language' => array(
        'description' => t('The {languages}.language of this node.'),
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
36
37
        'default' => '',
      ),
38
39
40
41
42
      'title' => array(
        'description' => t('The title of this node, always treated a non-markup plain text.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
43
44
        'default' => '',
      ),
45
46
47
48
      'uid' => array(
        'description' => t('The {users}.uid that owns this node; initially, this is the user that created it.'),
        'type' => 'int',
        'not null' => TRUE,
49
50
        'default' => 0,
      ),
51
52
53
54
      'status' => array(
        'description' => t('Boolean indicating whether the node is published (visible to non-administrators).'),
        'type' => 'int',
        'not null' => TRUE,
55
56
        'default' => 1,
      ),
57
58
59
60
      'created' => array(
        'description' => t('The Unix timestamp when the node was created.'),
        'type' => 'int',
        'not null' => TRUE,
61
62
        'default' => 0,
      ),
63
64
65
66
      'changed' => array(
        'description' => t('The Unix timestamp when the node was most recently saved.'),
        'type' => 'int',
        'not null' => TRUE,
67
68
        'default' => 0,
      ),
69
70
71
72
      'comment' => array(
        'description' => t('Whether comments are allowed on this node: 0 = no, 1 = read only, 2 = read/write.'),
        'type' => 'int',
        'not null' => TRUE,
73
74
        'default' => 0,
      ),
75
76
77
78
      'promote' => array(
        'description' => t('Boolean indicating whether the node should displayed on the front page.'),
        'type' => 'int',
        'not null' => TRUE,
79
80
        'default' => 0,
      ),
81
82
83
84
      'moderate' => array(
        'description' => t('Previously, a boolean indicating whether the node was "in moderation"; mostly no longer used.'),
        'type' => 'int',
        'not null' => TRUE,
85
86
        'default' => 0,
      ),
87
88
89
90
      'sticky' => array(
        'description' => t('Boolean indicating whether the node should be displayed at the top of lists in which it appears.'),
        'type' => 'int',
        'not null' => TRUE,
91
92
        'default' => 0,
      ),
93
94
95
96
97
      'tnid' => array(
        'description' => t('The translation set id for this node, which equals the node id of the source post in each set.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
98
99
        'default' => 0,
      ),
100
101
102
103
      'translate' => array(
        'description' => t('A boolean indicating whether this translation page needs to be updated.'),
        'type' => 'int',
        'not null' => TRUE,
104
        'default' => 0,
105
      ),
106
    ),
107
108
109
110
111
112
113
114
115
116
117
    'indexes' => array(
      'node_changed'        => array('changed'),
      'node_created'        => array('created'),
      'node_moderate'       => array('moderate'),
      'node_promote_status' => array('promote', 'status'),
      'node_status_type'    => array('status', 'type', 'nid'),
      'node_title_type'     => array('title', array('type', 4)),
      'node_type'           => array(array('type', 4)),
      'uid'                 => array('uid'),
      'tnid'                => array('tnid'),
      'translate'           => array('translate'),
118
    ),
119
    'unique keys' => array(
120
121
      'vid' => array('vid'),
    ),
122
    'primary key' => array('nid'),
123
  );
124
125

  $schema['node_access'] = array(
126
    'description' => t('Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.'),
127
    'fields' => array(
128
129
130
131
132
      'nid' => array(
        'description' => t('The {node}.nid this record affects.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
133
134
        'default' => 0,
      ),
135
136
137
138
139
      'gid' => array(
        'description' => t("The grant ID a user must possess in the specified realm to gain this row's privileges on the node."),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
140
141
        'default' => 0,
      ),
142
143
144
145
146
      'realm' => array(
        'description' => t('The realm in which the user must possess the grant ID. Each node access node can define one or more realms.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
147
148
        'default' => '',
      ),
149
150
151
152
153
154
      'grant_view' => array(
        'description' => t('Boolean indicating whether a user with the realm/grant pair can view this node.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
155
156
        'size' => 'tiny',
      ),
157
158
159
160
161
162
      'grant_update' => array(
        'description' => t('Boolean indicating whether a user with the realm/grant pair can edit this node.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
163
164
        'size' => 'tiny',
      ),
165
166
167
168
169
170
      'grant_delete' => array(
        'description' => t('Boolean indicating whether a user with the realm/grant pair can delete this node.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
171
        'size' => 'tiny',
172
      ),
173
    ),
174
    'primary key' => array('nid', 'gid', 'realm'),
175
  );
176
177

  $schema['node_counter'] = array(
178
    'description' => t('Access statistics for {node}s.'),
179
    'fields' => array(
180
181
182
183
      'nid' => array(
        'description' => t('The {node}.nid for these statistics.'),
        'type' => 'int',
        'not null' => TRUE,
184
185
        'default' => 0,
      ),
186
187
188
189
190
191
      'totalcount' => array(
        'description' => t('The total number of times the {node} has been viewed.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
192
193
        'size' => 'big',
      ),
194
195
196
197
198
199
      'daycount' => array(
        'description' => t('The total number of times the {node} has been viewed today.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
200
201
        'size' => 'medium',
      ),
202
203
204
205
206
      'timestamp' => array(
        'description' => t('The most recent time the {node} has been viewed.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
207
        'default' => 0,
208
      ),
209
    ),
210
    'primary key' => array('nid'),
211
  );
212
213

  $schema['node_revisions'] = array(
214
    'description' => t('Stores information about each saved version of a {node}.'),
215
    'fields' => array(
216
217
218
219
220
      'nid' => array(
        'description' => t('The {node} this version belongs to.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
221
222
        'default' => 0,
      ),
223
224
225
226
      'vid' => array(
        'description' => t('The primary identifier for this version.'),
        'type' => 'serial',
        'unsigned' => TRUE,
227
228
        'not null' => TRUE,
      ),
229
230
231
232
      'uid' => array(
        'description' => t('The {users}.uid that created this version.'),
        'type' => 'int',
        'not null' => TRUE,
233
234
        'default' => 0,
      ),
235
236
237
238
239
      'title' => array(
        'description' => t('The title of this version.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
240
241
        'default' => '',
      ),
242
243
244
245
      'body' => array(
        'description' => t('The body of this version.'),
        'type' => 'text',
        'not null' => TRUE,
246
247
        'size' => 'big',
      ),
248
249
250
251
      'teaser' => array(
        'description' => t('The teaser of this version.'),
        'type' => 'text',
        'not null' => TRUE,
252
253
        'size' => 'big',
      ),
254
255
256
257
      'log' => array(
        'description' => t('The log entry explaining the changes in this version.'),
        'type' => 'text',
        'not null' => TRUE,
258
259
        'size' => 'big',
      ),
260
261
262
263
      'timestamp' => array(
        'description' => t('A Unix timestamp indicating when this version was created.'),
        'type' => 'int',
        'not null' => TRUE,
264
265
        'default' => 0,
      ),
266
267
268
269
      'format' => array(
        'description' => t("The input format used by this version's body."),
        'type' => 'int',
        'not null' => TRUE,
270
        'default' => 0,
271
      ),
272
    ),
273
274
    'indexes' => array(
      'nid' => array('nid'),
275
276
      'uid' => array('uid'),
    ),
277
    'primary key' => array('vid'),
278
  );
279
280

  $schema['node_type'] = array(
281
    'description' => t('Stores information about all defined {node} types.'),
282
    'fields' => array(
283
284
285
286
      'type' => array(
        'description' => t('The machine-readable name of this type.'),
        'type' => 'varchar',
        'length' => 32,
287
288
        'not null' => TRUE,
      ),
289
290
291
292
293
      'name' => array(
        'description' => t('The human-readable name of this type.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
294
295
        'default' => '',
      ),
296
297
298
299
      'module' => array(
        'description' => t('The module that implements this type.'),
        'type' => 'varchar',
        'length' => 255,
300
301
302
        'not null' => TRUE,
      ),
      'description' => array(
303
304
305
        'description' => t('A brief description of this type.'),
        'type' => 'text',
        'not null' => TRUE,
306
307
        'size' => 'medium',
      ),
308
309
310
311
      'help' => array(
        'description' => t('Help information shown to the user when creating a {node} of this type.'),
        'type' => 'text',
        'not null' => TRUE,
312
313
        'size' => 'medium',
      ),
314
315
316
317
318
      'has_title' => array(
        'description' => t('Boolean indicating whether this type uses the {node}.title field.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
319
320
        'size' => 'tiny',
      ),
321
322
323
324
325
      'title_label' => array(
        'description' => t('The label displayed for the title field on the edit form.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
326
327
        'default' => '',
      ),
328
      'has_body' => array(
329
        'description' => t('Boolean indicating whether this type uses the {node_revisions}.body field.'),
330
331
332
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
333
334
        'size' => 'tiny',
      ),
335
336
337
338
339
      'body_label' => array(
        'description' => t('The label displayed for the body field on the edit form.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
340
341
        'default' => '',
      ),
342
343
344
345
346
      'min_word_count' => array(
        'description' => t('The minimum number of words the body must contain.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
347
348
        'size' => 'small',
      ),
349
350
351
352
353
      'custom' => array(
        'description' => t('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).'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
354
355
        'size' => 'tiny',
      ),
356
357
358
359
360
      'modified' => array(
        'description' => t('A boolean indicating whether this type has been modified by an administrator; currently not used in any way.'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
361
362
        'size' => 'tiny',
      ),
363
364
365
366
367
      'locked' => array(
        'description' => t('A boolean indicating whether the administrator can change the machine name of this type.'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
368
369
        'size' => 'tiny',
      ),
370
371
372
373
374
      'orig_type' => array(
        'description' => t('The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
375
        'default' => '',
376
      ),
377
    ),
378
    'primary key' => array('type'),
379
  );
380
381
382

  return $schema;
}