Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @file
- * Install, update and uninstall functions for the hello module.
- */
- use Drupal\Core\Database\Database;
- /**
- * Implements hook_schema().
- */
- function hello_schema() {
- $schema['hello_node_history'] = array(
- 'description' => 'Stores node update history.',
- 'fields' => array(
- 'hid' => array(
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'nid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'uid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'update_time' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('hid'),
- 'indexes' => array('nid' => array('nid')),
- );
- return $schema;
- }
- /**
- * Implements hook_update_N().
- */
- /**
- * Add a 'uid' field to the hello_node_history table.
- */
- function hello_update_8300() {
- $field_spec = array(
- 'type' => 'int',
- 'description' => "Store user ID.",
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- );
- $schema = Database::getConnection()->schema();
- $schema->addField('hello_node_history', 'uid', $field_spec);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement