8aa980d1285c159e7280f7910f69242a246b0baf
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / schema.twig
1 /**
2  * Implements hook_schema().
3  */
4 function {{ machine_name }}_schema() {
5   $schema['node'] = [
6     // Example (partial) specification for table "node".
7     'description' => 'The base table for nodes.',
8     'fields' => [
9       'nid' => [
10         'description' => 'The primary identifier for a node.',
11         'type' => 'serial',
12         'unsigned' => TRUE,
13         'not null' => TRUE,
14       ],
15       'vid' => [
16         'description' => 'The current {node_field_revision}.vid version identifier.',
17         'type' => 'int',
18         'unsigned' => TRUE,
19         'not null' => TRUE,
20         'default' => 0,
21       ],
22       'type' => [
23         'description' => 'The type of this node.',
24         'type' => 'varchar',
25         'length' => 32,
26         'not null' => TRUE,
27         'default' => '',
28       ],
29       'title' => [
30         'description' => 'The node title.',
31         'type' => 'varchar',
32         'length' => 255,
33         'not null' => TRUE,
34         'default' => '',
35       ],
36     ],
37     'indexes' => [
38       'node_changed'        => ['changed'],
39       'node_created'        => ['created'],
40     ],
41     'unique keys' => [
42       'nid_vid' => ['nid', 'vid'],
43       'vid'     => ['vid'],
44     ],
45     // For documentation purposes only; foreign keys are not created in the
46     // database.
47     'foreign keys' => [
48       'node_revision' => [
49         'table' => 'node_field_revision',
50         'columns' => ['vid' => 'vid'],
51       ],
52       'node_author' => [
53         'table' => 'users',
54         'columns' => ['uid' => 'uid'],
55       ],
56     ],
57     'primary key' => ['nid'],
58   ];
59   return $schema;
60 }