You are here

function skinr_update_7201 in Skinr 7.2

Add UUIDs.

File

./skinr.install, line 478
Contains install, update, and uninstall functions for Skinr.

Code

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

  // Include UUID functionality.
  if (!module_exists('uuid')) {
    module_load_include('inc', 'skinr', 'skinr.uuid');
  }

  // Add a UUID to all existing skins.
  $result = db_query("SELECT sid FROM {skinr_skins}");
  foreach ($result as $skin) {
    db_update('skinr_skins')
      ->fields(array(
      'uuid' => uuid_generate(),
    ))
      ->condition('sid', $skin->sid)
      ->isNull('uuid')
      ->execute();
  }
}