You are here

function system_update_110 in Drupal 5

Same name and namespace in other branches
  1. 4 database/updates.inc \system_update_110()

File

modules/system/system.install, line 1113

Code

function system_update_110() {
  $ret = array();

  // TODO: needs PGSQL version
  if ($GLOBALS['db_type'] == 'mysql') {

    /*
     ** Search
     */
    $ret[] = update_sql('DROP TABLE {search_index}');
    $ret[] = update_sql("CREATE TABLE {search_index} (\n      word varchar(50) NOT NULL default '',\n      sid int unsigned NOT NULL default '0',\n      type varchar(16) default NULL,\n      fromsid int unsigned NOT NULL default '0',\n      fromtype varchar(16) default NULL,\n      score int unsigned default NULL,\n      KEY sid (sid),\n      KEY fromsid (fromsid),\n      KEY word (word)\n      )");
    $ret[] = update_sql("CREATE TABLE {search_total} (\n      word varchar(50) NOT NULL default '',\n      count int unsigned default NULL,\n      PRIMARY KEY word (word)\n      )");

    /*
     ** Blocks
     */
    $ret[] = update_sql('ALTER TABLE {blocks} DROP path');
    $ret[] = update_sql('ALTER TABLE {blocks} ADD visibility tinyint NOT NULL');
    $ret[] = update_sql('ALTER TABLE {blocks} ADD pages text NOT NULL');
  }
  elseif ($GLOBALS['db_type'] == 'pgsql') {

    /*
     ** Search
     */
    $ret[] = update_sql('DROP TABLE {search_index}');
    $ret[] = update_sql("CREATE TABLE {search_index} (\n      word varchar(50) NOT NULL default '',\n      sid integer NOT NULL default '0',\n      type varchar(16) default NULL,\n      fromsid integer NOT NULL default '0',\n      fromtype varchar(16) default NULL,\n      score integer default NULL\n      )");
    $ret[] = update_sql("CREATE INDEX {search_index}_sid_idx on {search_index}(sid)");
    $ret[] = update_sql("CREATE INDEX {search_index}_fromsid_idx on {search_index}(fromsid)");
    $ret[] = update_sql("CREATE INDEX {search_index}_word_idx on {search_index}(word)");
    $ret[] = update_sql("CREATE TABLE {search_total} (\n      word varchar(50) NOT NULL default '' PRIMARY KEY,\n      count integer default NULL\n      )");

    /*
     ** Blocks
     */

    // Postgres can only drop columns since 7.4

    #$ret[] = update_sql('ALTER TABLE {blocks} DROP path');
    $ret[] = update_sql('ALTER TABLE {blocks} ADD visibility smallint');
    $ret[] = update_sql("ALTER TABLE {blocks} ALTER COLUMN visibility set default 0");
    $ret[] = update_sql('UPDATE {blocks} SET visibility = 0');
    $ret[] = update_sql('ALTER TABLE {blocks} ALTER COLUMN visibility SET NOT NULL');
    $ret[] = update_sql('ALTER TABLE {blocks} ADD pages text');
    $ret[] = update_sql("ALTER TABLE {blocks} ALTER COLUMN pages set default ''");
    $ret[] = update_sql("UPDATE {blocks} SET pages = ''");
    $ret[] = update_sql('ALTER TABLE {blocks} ALTER COLUMN pages SET NOT NULL');
  }
  $ret[] = update_sql("DELETE FROM {variable} WHERE name = 'node_cron_last'");
  $ret[] = update_sql('UPDATE {blocks} SET status = 1, custom = 2 WHERE status = 0 AND custom = 1');
  return $ret;
}