function block_update_8002

Replace serial role IDs with machine name strings.

See also

user_update_8002()

Related topics

File

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

Code

function block_update_8002() {

  // Change serial rid column into string.
  $column = array(
    'type' => 'varchar',
    'length' => 64,
    'not null' => TRUE,
    'description' => "The user's role ID from {users_roles}.rid.",
  );
  db_change_field('block_role', 'rid', 'rid', $column);

  // Rename the built-in serial role IDs into the hardcoded machine names.
  db_update('block_role')
    ->fields(array(
    'rid' => DRUPAL_ANONYMOUS_RID,
  ))
    ->condition('rid', 1)
    ->execute();
  db_update('block_role')
    ->fields(array(
    'rid' => DRUPAL_AUTHENTICATED_RID,
  ))
    ->condition('rid', 2)
    ->execute();
}