function faq_update_2 in Frequently Asked Questions 6
Same name and namespace in other branches
- 5.2 faq.install \faq_update_2()
- 7.2 faq.install \faq_update_2()
- 7 faq.install \faq_update_2()
Create 'faq_questions' table in order to upgrade from older installations.
Should have been created with faq_update_600x() naming convention, but too late now.
Return value
An array containing the results of the update.
File
- ./
faq.install, line 140 - FAQ module install file.
Code
function faq_update_2() {
$schema['faq_questions'] = array(
'description' => 'A table containing the long question text of each faq node revision.',
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The primary identifier for a node.',
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The primary identifier for a node revision.',
),
'question' => array(
'type' => 'text',
'size' => 'normal',
'not null' => TRUE,
'description' => 'The faq long question text.',
),
),
'primary key' => array(
'nid',
'vid',
),
);
$ret = array();
db_create_table($ret, 'faq_questions', $schema['faq_questions']);
$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;
}