node.install 12.6 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' => 'The base table for nodes.',
10
    'fields' => array(
11
      'nid' => array(
12
        'description' => 'The primary identifier for a node.',
13
14
        'type' => 'serial',
        'unsigned' => TRUE,
15
16
        'not null' => TRUE,
      ),
17
      'vid' => array(
18
        'description' => 'The current {node_revisions}.vid version identifier.',
19
20
21
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
22
23
        'default' => 0,
      ),
24
      'type' => array(
25
        'description' => 'The {node_type}.type of this node.',
26
27
28
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
29
30
        'default' => '',
      ),
31
      'language' => array(
32
        'description' => 'The {languages}.language of this node.',
33
34
35
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
36
37
        'default' => '',
      ),
38
      'title' => array(
39
        'description' => 'The title of this node, always treated as non-markup plain text.',
40
41
42
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
43
44
        'default' => '',
      ),
45
      'uid' => array(
46
        'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
47
48
        'type' => 'int',
        'not null' => TRUE,
49
50
        'default' => 0,
      ),
51
      'status' => array(
52
        'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
53
54
        'type' => 'int',
        'not null' => TRUE,
55
56
        'default' => 1,
      ),
57
      'created' => array(
58
        'description' => 'The Unix timestamp when the node was created.',
59
60
        'type' => 'int',
        'not null' => TRUE,
61
62
        'default' => 0,
      ),
63
      'changed' => array(
64
        'description' => 'The Unix timestamp when the node was most recently saved.',
65
66
        'type' => 'int',
        'not null' => TRUE,
67
68
        'default' => 0,
      ),
69
      'comment' => array(
70
        'description' => 'Whether comments are allowed on this node: 0 = no, 1 = read only, 2 = read/write.',
71
72
        'type' => 'int',
        'not null' => TRUE,
73
74
        'default' => 0,
      ),
75
      'promote' => array(
76
        'description' => 'Boolean indicating whether the node should be displayed on the front page.',
77
78
        'type' => 'int',
        'not null' => TRUE,
79
80
        'default' => 0,
      ),
81
      'moderate' => array(
82
        'description' => 'Previously, a boolean indicating whether the node was "in moderation"; mostly no longer used.',
83
84
        'type' => 'int',
        'not null' => TRUE,
85
86
        'default' => 0,
      ),
87
      'sticky' => array(
88
        'description' => 'Boolean indicating whether the node should be displayed at the top of lists in which it appears.',
89
90
        'type' => 'int',
        'not null' => TRUE,
91
92
        'default' => 0,
      ),
93
      'tnid' => array(
94
        'description' => 'The translation set id for this node, which equals the node id of the source post in each set.',
95
96
97
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
98
99
        'default' => 0,
      ),
100
      'translate' => array(
101
        'description' => 'A boolean indicating whether this translation page needs to be updated.',
102
103
        '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' => 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.',
127
    'fields' => array(
128
      'nid' => array(
129
        'description' => 'The {node}.nid this record affects.',
130
131
132
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
133
134
        'default' => 0,
      ),
135
      'gid' => array(
136
        'description' => "The grant ID a user must possess in the specified realm to gain this row's privileges on the node.",
137
138
139
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
140
141
        'default' => 0,
      ),
142
      'realm' => array(
143
        'description' => 'The realm in which the user must possess the grant ID. Each node access node can define one or more realms.',
144
145
146
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
147
148
        'default' => '',
      ),
149
      'grant_view' => array(
150
        'description' => 'Boolean indicating whether a user with the realm/grant pair can view this node.',
151
152
153
154
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
155
156
        'size' => 'tiny',
      ),
157
      'grant_update' => array(
158
        'description' => 'Boolean indicating whether a user with the realm/grant pair can edit this node.',
159
160
161
162
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
163
164
        'size' => 'tiny',
      ),
165
      'grant_delete' => array(
166
        'description' => 'Boolean indicating whether a user with the realm/grant pair can delete this node.',
167
168
169
170
        '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' => 'Access statistics for {node}s.',
179
    'fields' => array(
180
      'nid' => array(
181
        'description' => 'The {node}.nid for these statistics.',
182
183
        'type' => 'int',
        'not null' => TRUE,
184
185
        'default' => 0,
      ),
186
      'totalcount' => array(
187
        'description' => 'The total number of times the {node} has been viewed.',
188
189
190
191
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
192
193
        'size' => 'big',
      ),
194
      'daycount' => array(
195
        'description' => 'The total number of times the {node} has been viewed today.',
196
197
198
199
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
200
201
        'size' => 'medium',
      ),
202
      'timestamp' => array(
203
        'description' => 'The most recent time the {node} has been viewed.',
204
205
206
        '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' => 'Stores information about each saved version of a {node}.',
215
    'fields' => array(
216
      'nid' => array(
217
        'description' => 'The {node} this version belongs to.',
218
219
220
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
221
222
        'default' => 0,
      ),
223
      'vid' => array(
224
        'description' => 'The primary identifier for this version.',
225
226
        'type' => 'serial',
        'unsigned' => TRUE,
227
228
        'not null' => TRUE,
      ),
229
      'uid' => array(
230
        'description' => 'The {users}.uid that created this version.',
231
232
        'type' => 'int',
        'not null' => TRUE,
233
234
        'default' => 0,
      ),
235
      'title' => array(
236
        'description' => 'The title of this version.',
237
238
239
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
240
241
        'default' => '',
      ),
242
      'body' => array(
243
        'description' => 'The body of this version.',
244
245
        'type' => 'text',
        'not null' => TRUE,
246
247
        'size' => 'big',
      ),
248
      'teaser' => array(
249
        'description' => 'The teaser of this version.',
250
251
        'type' => 'text',
        'not null' => TRUE,
252
253
        'size' => 'big',
      ),
254
      'log' => array(
255
        'description' => 'The log entry explaining the changes in this version.',
256
257
        'type' => 'text',
        'not null' => TRUE,
258
259
        'size' => 'big',
      ),
260
      'timestamp' => array(
261
        'description' => 'A Unix timestamp indicating when this version was created.',
262
263
        'type' => 'int',
        'not null' => TRUE,
264
265
        'default' => 0,
      ),
266
      'format' => array(
267
        'description' => "The input format used by this version's body.",
268
269
        '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' => 'Stores information about all defined {node} types.',
282
    'fields' => array(
283
      'type' => array(
284
        'description' => 'The machine-readable name of this type.',
285
286
        'type' => 'varchar',
        'length' => 32,
287
288
        'not null' => TRUE,
      ),
289
      'name' => array(
290
        'description' => 'The human-readable name of this type.',
291
292
293
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
294
295
        'default' => '',
      ),
296
      'base' => array(
297
        'description' => 'The base string used to construct callbacks corresponding to this node type.',
298
299
        'type' => 'varchar',
        'length' => 255,
300
301
302
        'not null' => TRUE,
      ),
      'description' => array(
303
        'description' => 'A brief description of this type.',
304
305
        'type' => 'text',
        'not null' => TRUE,
306
307
        'size' => 'medium',
      ),
308
      'help' => array(
309
        'description' => 'Help information shown to the user when creating a {node} of this type.',
310
311
        'type' => 'text',
        'not null' => TRUE,
312
313
        'size' => 'medium',
      ),
314
      'has_title' => array(
315
        'description' => 'Boolean indicating whether this type uses the {node}.title field.',
316
317
318
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
319
320
        'size' => 'tiny',
      ),
321
      'title_label' => array(
322
        'description' => 'The label displayed for the title field on the edit form.',
323
324
325
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
326
327
        'default' => '',
      ),
328
      'has_body' => array(
329
        'description' => '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
      'body_label' => array(
336
        'description' => 'The label displayed for the body field on the edit form.',
337
338
339
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
340
341
        'default' => '',
      ),
342
      'min_word_count' => array(
343
        'description' => 'The minimum number of words the body must contain.',
344
345
346
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
347
348
        'size' => 'small',
      ),
349
      'custom' => array(
350
        '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).',
351
352
353
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
354
355
        'size' => 'tiny',
      ),
356
      'modified' => array(
357
        'description' => 'A boolean indicating whether this type has been modified by an administrator; currently not used in any way.',
358
359
360
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
361
362
        'size' => 'tiny',
      ),
363
      'locked' => array(
364
        'description' => 'A boolean indicating whether the administrator can change the machine name of this type.',
365
366
367
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
368
369
        'size' => 'tiny',
      ),
370
      'orig_type' => array(
371
        '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.',
372
373
374
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
375
        'default' => '',
376
      ),
377
    ),
378
    'primary key' => array('type'),
379
  );
380
381
382

  return $schema;
}
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402

/**
 * Drupal 6.x to 7.x updates
 */

/**
 * Fix node type 'module' attribute to avoid name-space conflicts.
 */
function node_update_7000() {
  $ret = array();

  $ret[] = update_sql("UPDATE {node_type} SET module = 'node_content' WHERE module = 'node'");
  db_change_field($ret, 'node_type', 'module', 'base', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));

  return $ret;
}

/**
 * End of 6.x to 7.x updates
 */