function system_update_8015

Create a UUID column for managed files.

Related topics

File

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

Code

function system_update_8015() {
  $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('file_managed', 'uuid')) {
    db_change_field('file_managed', 'uuid', 'uuid', $spec, $keys);
  }
  else {
    db_add_field('file_managed', 'uuid', $spec, $keys);
  }
}