You are here

function freelinking_update_2 in Freelinking 6

Same name and namespace in other branches
  1. 5 freelinking.install \freelinking_update_2()
  2. 6.2 freelinking.install \freelinking_update_2()

File

./freelinking.install, line 56

Code

function freelinking_update_2() {

  // this is the update to the 4.7 version
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql('ALTER TABLE {freelinking} ADD COLUMN hash CHAR(32)');
      $ret[] = update_sql('ALTER TABLE {freelinking} ADD COLUMN path VARCHAR(200)');
      $ret[] = update_sql('ALTER TABLE {freelinking} ADD COLUMN args VARCHAR(200)');
      $ret[] = update_sql('UPDATE      {freelinking} SET path = target');
      $ret[] = update_sql('UPDATE      {freelinking} SET hash = MD5(CONCAT(phrase, path))');
      $ret[] = update_sql('ALTER TABLE {freelinking} DROP COLUMN target');
      $ret[] = update_sql('ALTER TABLE {freelinking} ADD PRIMARY KEY hash (hash)');
      break;
    case 'pgsql':
      $ret[] = update_sql('ALTER TABLE {freelinking} DROP COLUMN target');
      db_add_column($ret, 'freelinking', 'hash', 'char(32)');
      db_add_column($ret, 'freelinking', 'path', 'varchar(200)');
      db_add_column($ret, 'freelinking', 'args', 'varchar(200)');
      $ret[] = update_sql('ALTER TABLE {freelinking} ADD PRIMARY KEY hash');
      break;
  }

  // endswitch db_table
  return $ret;
}