Skip to content
Snippets Groups Projects
updates.inc 71.3 KiB
Newer Older
Dries Buytaert's avatar
Dries Buytaert committed
<?php
/* $Id$ */

Dries Buytaert's avatar
 
Dries Buytaert committed
/**
 * @file
 * All incremental database updates performed between Drupal releases.
 */

Dries Buytaert's avatar
Dries Buytaert committed
// Define the various updates in an array("date : comment" => "function");
$sql_updates = array(
  "2002-06-22: first update since Drupal 4.0.0 release" => "update_32",
  "2002-07-07" => "update_33",
  "2002-07-31" => "update_34",
  "2002-08-10" => "update_35",
  "2002-08-16" => "update_36",
  "2002-08-19" => "update_37",
  "2002-08-26" => "update_38",
  "2002-09-15" => "update_39",
  "2002-09-17" => "update_40",
  "2002-10-13" => "update_41",
  "2002-10-17" => "update_42",
  "2002-10-26" => "update_43",
  "2002-11-08" => "update_44",
  "2002-11-20" => "update_45",
  "2002-12-10: first update since Drupal 4.1.0 release" => "update_46",
  "2002-12-29" => "update_47",
  "2003-01-03" => "update_48",
  "2003-01-05" => "update_49",
  "2003-01-15" => "update_50",
  "2003-04-19" => "update_51",
  "2003-04-20" => "update_52",
  "2003-05-18" => "update_53",
  "2003-05-24" => "update_54",
  "2003-05-31" => "update_55",
  "2003-06-04" => "update_56",
  "2003-06-08" => "update_57",
  "2003-06-08: first update since Drupal 4.2.0 release" => "update_58",
  "2003-08-05" => "update_59",
  "2003-08-15" => "update_60",
  "2003-08-20" => "update_61",
  "2003-08-27" => "update_62",
  "2003-09-09" => "update_63",
  "2003-09-10" => "update_64",
  "2003-09-29" => "update_65",
  "2003-09-30" => "update_66",
  "2003-10-11" => "update_67",
  "2003-10-20" => "update_68",
  "2003-10-22" => "update_69",
  "2003-10-27" => "update_70",
  "2003-11-17: first update since Drupal 4.3.0 release" => "update_71",
  "2003-11-27" => "update_72",
  "2003-12-03" => "update_73",
  "2003-12-06" => "update_74",
  "2004-01-06" => "update_75",
  "2004-01-11" => "update_76",
  "2004-01-13" => "update_77",
  "2004-02-03" => "update_78",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-02-21" => "update_79",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-03-11: first update since Drupal 4.4.0 release" => "update_80",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-02-20" => "update_81",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-04-21" => "update_84",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-04-27" => "update_85",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-05-10" => "update_86",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-05-18" => "update_87",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-06-11" => "update_88",
  "2004-06-18" => "update_89",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-06-30" => "update_91",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-07-07" => "update_92",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-07-11" => "update_93",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-07-22" => "update_94",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-07-30" => "update_95",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-08-09" => "update_99",
  "2004-08-10" => "update_100",
  "2004-08-11" => "update_101",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-08-12" => "update_102",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-08-17" => "update_103",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-08-19" => "update_104",
  "2004-09-14" => "update_105",
Dries Buytaert's avatar
 
Dries Buytaert committed
  "2004-09-15" => "update_106",
  "2004-09-17" => "update_107",
  "2004-10-18" => "update_109",
  "2004-10-31: first update since Drupal 4.5.0 release" => "update_110"
Dries Buytaert's avatar
Dries Buytaert committed
);

function update_32() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE users ADD index (sid(4))");
  $ret[] = update_sql("ALTER TABLE users ADD index (timestamp)");
  $ret[] = update_sql("ALTER TABLE users ADD UNIQUE KEY name (name)");
  return $ret;
}

function update_33() {
  $ret = array();
  $result = db_query("SELECT * FROM variable WHERE value NOT LIKE 's:%;'");
  // NOTE: the "WHERE"-part of the query above avoids variables to get serialized twice.
  while ($variable = db_fetch_object($result)) {
    variable_set($variable->name, $variable->value);
  }
  return $ret;
}

function update_34() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE feed MODIFY refresh int(10) NOT NULL default '0'");
  $ret[] = update_sql("ALTER TABLE feed MODIFY timestamp int (10) NOT NULL default '0'");
  $ret[] = update_sql("ALTER TABLE users CHANGE session session TEXT");
  return $ret;
}

function update_35() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE poll_choices ADD INDEX (nid)");
  return $ret;
}

function update_36() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE rating CHANGE old previous int(6) NOT NULL default '0'");
  $ret[] = update_sql("ALTER TABLE rating CHANGE new current int(6) NOT NULL default '0'");
  return $ret;
}

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

  $ret[] = update_sql("DROP TABLE IF EXISTS sequences");

  $ret[] = update_sql("CREATE TABLE sequences (
    name VARCHAR(255) NOT NULL PRIMARY KEY,
    id INT UNSIGNED NOT NULL
  ) TYPE=MyISAM");

  if ($max = db_result(db_query("SELECT MAX(nid) FROM node"))) {
    $ret[] = update_sql("REPLACE INTO sequences VALUES ('node', $max)");
  }

  if ($max = db_result(db_query("SELECT MAX(cid) FROM comments"))) {
    $ret[] = update_sql("REPLACE INTO sequences VALUES ('comments', $max)");
  }
  // NOTE: move the comments bit down as soon as we switched to use the new comment module!

  if ($max = db_result(db_query("SELECT MAX(tid) FROM term_data"))) {
    $ret[] = update_sql("REPLACE INTO sequences VALUES ('term_data', $max)");
  }
  return $ret;
}

function update_38() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE watchdog CHANGE message message text NOT NULL default ''");
  return $ret;
}

function update_39() {
  $ret = array();
  $ret[] = update_sql("DROP TABLE moderate");

  $ret[] = update_sql("ALTER TABLE comments ADD score MEDIUMINT NOT NULL");
  $ret[] = update_sql("ALTER TABLE comments ADD status TINYINT UNSIGNED NOT NULL");
  $ret[] = update_sql("ALTER TABLE comments ADD users MEDIUMTEXT");

  $ret[] = update_sql("CREATE TABLE moderation_votes (
    mid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    vote VARCHAR(255),
    weight TINYINT NOT NULL
  )");

  $ret[] = update_sql("CREATE TABLE moderation_roles (
    rid INT UNSIGNED NOT NULL,
    mid INT UNSIGNED NOT NULL,
    value TINYINT NOT NULL
  )");

  $ret[] = update_sql("ALTER TABLE moderation_roles ADD INDEX (rid)");
  $ret[] = update_sql("ALTER TABLE moderation_roles ADD INDEX (mid)");

  $ret[] = update_sql("CREATE TABLE moderation_filters (
    fid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    filter VARCHAR(255) NOT NULL,
    minimum SMALLINT NOT NULL
  )");

  $ret[] = update_sql("DELETE FROM moderation_votes");
  $ret[] = update_sql("INSERT INTO moderation_votes VALUES (1, '+1', 0)");
  $ret[] = update_sql("INSERT INTO moderation_votes VALUES (2, '-1', 1)");

  $ret[] = update_sql("DELETE FROM moderation_roles");
  $ret[] = update_sql("INSERT INTO moderation_roles VALUES (2, 1, 1)");
  $ret[] = update_sql("INSERT INTO moderation_roles VALUES (2, 2, -1)");

  $ret[] = update_sql("CREATE TABLE forum (
    nid int unsigned not null primary key,
Loading
Loading full blame...