function translation_overview_update_6000 in Translation Overview 6.2
Create the {translation_overview_priority} table.
File
- ./
translation_overview.install, line 61
Code
function translation_overview_update_6000() {
$ret = array();
// Make sure the module is loaded so we have access to translation_overview_field_name().
module_load_include('module', 'translation_overview');
$schema['translation_overview_priority'] = array(
'description' => t('Track the priority in which nodes should be translated into various languages.'),
'fields' => array(
'tnid' => array(
'description' => t('The identifier for a node or set of node translations.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array(
'tnid',
),
);
// And dynamically assemble the table with a column per languages. Call
// language_list() with $reset = TRUE in case the languages have changed.
foreach (language_list('language', TRUE) as $lang_code => $language) {
$field = db_escape_table($lang_code);
$schema['translation_overview_priority']['fields'][$field] = array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
// The default should be equivalent to TRANSLATION_OVERVIEW_NORMAL
// which isn't defined since the module hasn't been loaded yet.
'default' => 1,
);
$schema['translation_overview_priority']['indexes'][$field] = array(
$field,
);
}
db_create_table($ret, 'translation_overview_priority', $schema['translation_overview_priority']);
// Insert records for all the source nodes, and untranslated nodes.
$ret[] = update_sql('INSERT INTO {translation_overview_priority} (tnid) SELECT DISTINCT(nid) FROM {node} WHERE nid = tnid OR tnid = 0 OR tnid IS NULL ORDER BY tnid');
return $ret;
}