You are here

function casetracker_update_19 in Case Tracker 5

File

./casetracker.install, line 527

Code

function casetracker_update_19() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {casetracker_comment_status} ADD cid int(10) NOT NULL default '0' AFTER sid");
      $results = db_query('SELECT cid, sid FROM {casetracker_comment}');

      // merge 'em all into one table now.
      while ($result = db_fetch_object($results)) {

        // the casetracker_comment table was unnecessary abstraction.
        db_query('UPDATE {casetracker_comment_status} SET cid = %d WHERE sid = %d', $result->cid, $result->sid);
      }
      $ret[] = update_sql('DROP TABLE {casetracker_comment}');

      // buh-bye. @todo insert bug here somewhere.
      $ret[] = update_sql('ALTER TABLE {casetracker_comment_status} DROP COLUMN sid');
      break;
  }
  return $ret;
}