1 block.install block_update_1001()

Add a column for title to the block_custom table.

Related topics

File

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

Code

function block_update_1001() {
  if (db_field_exists('block_custom', 'title')) {
    return;
  }

  $schema = array(
    'type' => 'varchar',
    'length' => 128,
    'not null' => TRUE,
    'default' => '',
    'description' => 'Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)',
    'translatable' => TRUE,
  );
  db_add_field('block_custom', 'title', $schema);

  $result = db_query("SELECT * FROM {block} WHERE module = 'block'");
  foreach ($result as $row) {
    db_update('block_custom')
      ->condition('bid', $row->delta)
      ->fields(array(
        'title' => $row->title,
      ))
      ->execute();
  }
}