function xmlsitemap_update_6100 in XML sitemap 6
Implementation of hook_update_N().
File
- ./
xmlsitemap.install, line 127 - Installation file for XML sitemap.
Code
function xmlsitemap_update_6100() {
$ret = array();
if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql('DROP FUNCTION IF EXISTS first(anyelement, anyelement);');
$result = @update_sql("DROP AGGREGATE first(anyelement)");
if ($result['success']) {
$ret[] = $result;
}
}
if (db_table_exists('xmlsitemap_additional')) {
db_drop_table($ret, 'xmlsitemap_additional');
}
if (db_table_exists('xmlsitemap')) {
$result = array();
@db_drop_primary_key($result, 'xmlsitemap');
if ($result[0]['success']) {
$ret[] = $result[0];
}
$result = array();
@db_drop_index($result, 'xmlsitemap', 'link_module');
if ($result[0]['success']) {
$ret[] = $result[0];
}
$result = array();
@db_drop_index($result, 'xmlsitemap', 'link_type');
if ($result[0]['success']) {
$ret[] = $result[0];
}
$result = array();
@db_drop_index($result, 'xmlsitemap', 'link_changed');
if ($result[0]['success']) {
$ret[] = $result[0];
}
$result = array();
@db_drop_index($result, 'xmlsitemap', 'link_priority');
if ($result[0]['success']) {
$ret[] = $result[0];
}
if (!db_column_exists('xmlsitemap', 'lid')) {
db_add_field($ret, 'xmlsitemap', 'lid', array(
'description' => 'The primary key.',
'type' => 'serial',
'not null' => TRUE,
), array(
'primary key' => array(
'lid',
),
));
}
db_change_field($ret, 'xmlsitemap', 'loc', 'loc', array(
'description' => 'The relative URL.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
));
if (db_column_exists('xmlsitemap', 'module')) {
db_change_field($ret, 'xmlsitemap', 'module', 'module', array(
'description' => 'The module handling this link.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
), array(
'indexes' => array(
'link_module' => array(
array(
'module',
25,
),
),
),
));
}
else {
db_add_field($ret, 'xmlsitemap', 'module', array(
'description' => 'The module handling this link.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
), array(
'indexes' => array(
'link_module' => array(
array(
'module',
25,
),
),
),
));
}
if (db_column_exists('xmlsitemap', 'type')) {
db_change_field($ret, 'xmlsitemap', 'type', 'type', array(
'description' => 'The type of link.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
));
}
else {
db_add_field($ret, 'xmlsitemap', 'type', array(
'description' => 'The type of link.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
));
}
if (!db_column_exists('xmlsitemap', 'id')) {
db_add_field($ret, 'xmlsitemap', 'id', array(
'description' => 'The ID associated with the link.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
}
if (!db_column_exists('xmlsitemap', 'sid')) {
db_add_field($ret, 'xmlsitemap', 'sid', array(
'description' => 'The sub ID associated with the link.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
}
if (!db_column_exists('xmlsitemap', 'language')) {
db_add_field($ret, 'xmlsitemap', 'language', array(
'description' => 'The language associated with the link.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
), array(
'indexes' => array(
'link_language' => array(
'language',
),
),
));
}
if (db_column_exists('xmlsitemap', 'lastmod')) {
db_change_field($ret, 'xmlsitemap', 'lastmod', 'changed', array(
'description' => 'The Unix timestamp of the last change.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
), array(
'indexes' => array(
'link_changed' => array(
'changed',
),
),
));
}
else {
if (!db_column_exists('xmlsitemap', 'changed')) {
db_add_field($ret, 'xmlsitemap', 'changed', array(
'description' => 'The Unix timestamp of the last change.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
), array(
'indexes' => array(
'link_changed' => array(
'changed',
),
),
));
}
}
if (db_column_exists('xmlsitemap', 'changefreq')) {
db_change_field($ret, 'xmlsitemap', 'changefreq', 'changefreq', array(
'description' => 'The frequency of the changes.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
}
if (db_column_exists('xmlsitemap', 'priority')) {
db_change_field($ret, 'xmlsitemap', 'priority', 'priority', array(
'description' => 'The priority of this node in the sitemap.',
'type' => 'float',
'not null' => TRUE,
'default' => 0.5,
), array(
'indexes' => array(
'link_priority' => array(
'priority',
),
),
));
}
}
else {
db_create_table($ret, 'xmlsitemap', array(
'description' => 'The base table for xmlsitemap.',
'fields' => array(
'lid' => array(
'description' => 'The primary key.',
'type' => 'serial',
'not null' => TRUE,
),
'loc' => array(
'description' => 'The relative URL.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'module' => array(
'description' => 'The module handling this link.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'type' => array(
'description' => 'The type of link.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'id' => array(
'description' => 'The ID associated with the link.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'sid' => array(
'description' => 'The sub ID associated with the link.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'language' => array(
'description' => 'The language associated with the link.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
),
'changed' => array(
'description' => 'The Unix timestamp of the last change.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'changefreq' => array(
'description' => 'The frequency of the changes.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'priority' => array(
'description' => 'The priority of this node in the sitemap.',
'type' => 'float',
'not null' => TRUE,
'default' => 0.5,
),
),
'indexes' => array(
'link_module' => array(
array(
'module',
25,
),
),
'link_language' => array(
'language',
),
'link_changed' => array(
'changed',
),
'link_priority' => array(
'priority',
),
),
'primary key' => array(
'lid',
),
));
}
if (module_exists('xmlsitemap_file')) {
module_disable(array(
'xmlsitemap_file',
));
}
if (module_exists('xmlsitemap_helper')) {
module_disable(array(
'xmlsitemap_helper',
));
}
$ret[] = update_sql("DELETE FROM {system} WHERE name IN ('xmlsitemap_file', 'xmlsitemap_helper') AND type = 'module'");
if (db_table_exists('xmlsitemap_file')) {
db_drop_table($ret, 'xmlsitemap_file');
}
if (!variable_get('menu_rebuild_needed', FALSE)) {
variable_set('menu_rebuild_needed', TRUE);
$ret[] = array(
'success' => TRUE,
'query' => 'Updated the menu callbacks successfully.',
);
}
module_rebuild_cache();
$ret[] = array(
'success' => TRUE,
'query' => 'Updated the module list successfully.',
);
return $ret;
}