Advertisement
Guest User

.install

a guest
Apr 20th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @file
  5.  * Install, update and uninstall functions for the hello module.
  6.  */
  7.  
  8. use Drupal\Core\Database\Database;
  9.  
  10. /**
  11.  * Implements hook_schema().
  12.  */
  13. function hello_schema() {
  14.   $schema['hello_node_history'] = array(
  15.     'description' => 'Stores node update history.',
  16.     'fields' => array(
  17.       'hid' => array(
  18.         'type'        => 'serial',
  19.         'unsigned'    => TRUE,
  20.         'not null'    => TRUE,
  21.       ),
  22.       'nid' => array(
  23.         'type'        => 'int',
  24.         'unsigned'    => TRUE,
  25.         'not null'    => TRUE,
  26.       ),
  27.       'uid' => array(
  28.         'type'        => 'int',
  29.         'unsigned'    => TRUE,
  30.         'not null'    => TRUE,
  31.       ),
  32.       'update_time' => array(
  33.         'type'        => 'int',
  34.         'unsigned'    => TRUE,
  35.         'not null'    => TRUE,
  36.       ),
  37.     ),
  38.     'primary key' => array('hid'),
  39.     'indexes' => array('nid' => array('nid')),
  40.   );
  41.   return $schema;
  42. }
  43.  
  44. /**
  45.  * Implements hook_update_N().
  46.  */
  47. /**
  48.  * Add a 'uid' field to the hello_node_history table.
  49.  */
  50. function hello_update_8300() {
  51.   $field_spec = array(
  52.     'type'        => 'int',
  53.     'description' => "Store user ID.",
  54.     'unsigned'    => TRUE,
  55.     'not null'    => TRUE,
  56.   );
  57.   $schema = Database::getConnection()->schema();
  58.   $schema->addField('hello_node_history', 'uid', $field_spec);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement