function node_update_8004

Create a UUID column for nodes.

Related topics

File

drupal/core/modules/node/node.install, line 631
Install, update and uninstall functions for the node module.

Code

function node_update_8004() {
  $spec = array(
    'description' => 'Unique Key: Universally unique identifier for this entity.',
    'type' => 'varchar',
    'length' => 128,
    'not null' => FALSE,
  );
  $keys = array(
    'unique keys' => array(
      'uuid' => array(
        'uuid',
      ),
    ),
  );

  // Account for sites having the contributed UUID module installed.
  if (db_field_exists('node', 'uuid')) {
    db_change_field('node', 'uuid', 'uuid', $spec, $keys);
  }
  else {
    db_add_field('node', 'uuid', $spec, $keys);
  }
}