You are here

function faq_update_2 in Frequently Asked Questions 5.2

Same name and namespace in other branches
  1. 6 faq.install \faq_update_2()
  2. 7.2 faq.install \faq_update_2()
  3. 7 faq.install \faq_update_2()

Create the new 'faq_questions' table in order to upgrade from older installations.

Return value

An array containing the structure of the SQL schema.

File

./faq.install, line 148
FAQ module install file.

Code

function faq_update_2() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE IF NOT EXISTS {faq_questions} (\n        nid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n        vid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n        question text NOT NULL,\n        PRIMARY KEY (nid, vid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $ret[] = update_sql('CREATE TABLE {faq_questions} (
        nid integer NOT NULL DEFAULT 0,
        vid integer NOT NULL DEFAULT 0,
        question text NOT NULL,
        PRIMARY KEY (nid, vid)
      );');
      break;
  }
  $ret[] = update_sql("INSERT INTO {faq_questions} (nid, vid, question) SELECT r.nid, r.vid, r.title FROM {node_revisions} r, {node} n WHERE n.nid = r.nid AND n.type = 'faq'");
  return $ret;
}