You are here

function system_update_1006 in Drupal 5

Related topics

File

modules/system/system.install, line 3285

Code

function system_update_1006() {

  // Add a customizable title to all blocks.
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {blocks} ADD title VARCHAR(64) NOT NULL DEFAULT ''");
      break;
    case 'pgsql':
      db_add_column($ret, 'blocks', 'title', 'varchar(64)', array(
        'default' => "''",
        'not null' => TRUE,
      ));
      break;
  }

  // Migrate custom block titles to new column.
  $boxes = db_query('SELECT bid, title from {boxes}');
  while ($box = db_fetch_object($boxes)) {
    db_query("UPDATE {blocks} SET title = '%s' WHERE delta = %d and module = 'block'", $box->title, $box->bid);
  }
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql('ALTER TABLE {boxes} DROP title');
      break;
    case 'pgsql':
      $ret[] = update_sql('ALTER TABLE {boxes} DROP COLUMN title');
      break;
  }
  return $ret;
}