You are here

function xmlsitemap_update_6204 in XML sitemap 6.2

Same name and namespace in other branches
  1. 7.2 xmlsitemap.install \xmlsitemap_update_6204()

Convert {xmlsitemap}.context_hash to replace {xmlsitemap}.smid.

File

./xmlsitemap.install, line 678
Install, update and uninstall functions for the xmlsitemap module.

Code

function xmlsitemap_update_6204() {
  $ret = array();
  if (db_column_exists('xmlsitemap_sitemap', 'context_hash')) {
    db_drop_unique_key($ret, 'xmlsitemap_sitemap', 'context_hash');
    db_drop_field($ret, 'xmlsitemap_sitemap', 'smid');

    // Rename context_hash to the new smid column.
    $smid_field = array(
      'description' => 'The sitemap ID (the hashed value of {xmlsitemap}.context.',
      'type' => 'varchar',
      'length' => 64,
      'not null' => TRUE,
    );
    db_change_field($ret, 'xmlsitemap_sitemap', 'context_hash', 'smid', $smid_field);

    // Remove and re-add the primary key now that the smid field is changed.
    // We don't need to drop the primary key since we already dropped the field
    // that was the primary key.
    db_add_primary_key($ret, 'xmlsitemap_sitemap', array(
      'smid',
    ));
  }
  _xmlsitemap_sitemap_rehash_all();
  return $ret;
}