You are here

function _uuid_install_uuid_fields in Universally Unique IDentifier 7

Install the uuid and vuuid fields for Drupal core entity tables where needed.

IMPORTANT: This function is called both at install and update time. If this method is modified to add additional fields in the future, the update strategy must be considered. See the comment in uuid_update_7102.

2 calls to _uuid_install_uuid_fields()
uuid_install in ./uuid.install
Implements hook_install().
uuid_update_7102 in ./uuid.install
Ensure that the uuid and vuuid fields are added where needed.

File

./uuid.install, line 74
Install, update and uninstall functions for the uuid module.

Code

function _uuid_install_uuid_fields() {
  $field = uuid_schema_field_definition();
  foreach (uuid_get_core_entity_info() as $info) {
    if (!db_field_exists($info['base table'], $info['entity keys']['uuid'])) {
      db_add_field($info['base table'], $info['entity keys']['uuid'], $field);
      db_add_index($info['base table'], $info['entity keys']['uuid'], array(
        $info['entity keys']['uuid'],
      ));
    }
    if (!empty($info['revision table']) && !empty($info['entity keys']['revision uuid'])) {
      if (!db_field_exists($info['revision table'], $info['entity keys']['revision uuid'])) {
        db_add_field($info['revision table'], $info['entity keys']['revision uuid'], $field);
        db_add_index($info['revision table'], $info['entity keys']['revision uuid'], array(
          $info['entity keys']['revision uuid'],
        ));
      }
    }
  }
}