You are here

function xmlsitemap_taxonomy_update_6100 in XML sitemap 6

Implementation of hook_update_N(). Updates the SQL tables.

File

xmlsitemap_taxonomy/xmlsitemap_taxonomy.install, line 88
Installation file for XML sitemap term.

Code

function xmlsitemap_taxonomy_update_6100() {
  $ret = array();
  if (db_table_exists('xmlsitemap_taxonomy')) {
    if (db_column_exists('xmlsitemap_taxonomy', 'pid')) {
      $result = array();
      @db_drop_index($result, 'xmlsitemap_taxonomy', 'pid');
      if ($result[0]['success']) {
        $ret[] = $result[0];
      }
      db_drop_field($ret, 'xmlsitemap_taxonomy', 'pid');
    }
    $result = array();
    @db_drop_primary_key($result, 'xmlsitemap_taxonomy');
    if ($result[0]['success']) {
      $ret[] = $result[0];
    }
    if (db_column_exists('xmlsitemap_taxonomy', 'tid')) {
      db_change_field($ret, 'xmlsitemap_taxonomy', 'tid', 'tid', array(
        'description' => 'The vocabulary term ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ), array(
        'primary key' => array(
          'tid',
        ),
      ));
    }
    else {
      db_add_field($ret, 'xmlsitemap_taxonomy', 'tid', array(
        'description' => 'The vocabulary term ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ), array(
        'primary key' => array(
          'tid',
        ),
      ));
    }
    if (!db_column_exists('xmlsitemap_taxonomy', 'vid')) {
      db_add_field($ret, 'xmlsitemap_taxonomy', 'vid', array(
        'description' => 'The vocabulary ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ));
    }
    if (db_column_exists('xmlsitemap_taxonomy', 'last_changed')) {
      db_change_field($ret, 'xmlsitemap_taxonomy', 'last_changed', 'changed', array(
        'description' => 'The Unix timestamp of the last change.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ));
    }
    else {
      if (!db_column_exists('xmlsitemap_taxonomy', 'changed')) {
        db_add_field($ret, 'xmlsitemap_taxonomy', 'changed', array(
          'description' => 'The Unix timestamp of the last change.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ));
      }
      else {
        db_change_field($ret, 'xmlsitemap_taxonomy', 'changed', 'changed', array(
          'description' => 'The Unix timestamp of the last change.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ));
      }
    }
    if (!db_column_exists('xmlsitemap_taxonomy', 'previously_changed')) {
      db_add_field($ret, 'xmlsitemap_taxonomy', 'previously_changed', array(
        'description' => 'The Unix timestamp of the previous change.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ));
    }
    else {
      db_change_field($ret, 'xmlsitemap_taxonomy', 'previously_changed', 'previously_changed', array(
        'description' => 'The Unix timestamp of the previous change.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ));
    }
    $ret[] = update_sql("UPDATE {xmlsitemap_taxonomy}\n      SET priority_override = -2.0\n      WHERE priority_override IS NULL");
    db_change_field($ret, 'xmlsitemap_taxonomy', 'priority_override', 'priority_override', array(
      'description' => 'The priority of the term in the sitemap.',
      'type' => 'float',
      'not null' => TRUE,
      'default' => -2.0,
    ));
  }
  else {
    db_create_table($ret, 'xmlsitemap_taxonomy', array(
      'description' => 'The base table for xmlsitemap_taxonomy.',
      'fields' => array(
        'tid' => array(
          'description' => 'The vocabulary term ID.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'vid' => array(
          'description' => 'The vocabulary ID.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'changed' => array(
          'description' => 'The Unix timestamp of the last change.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'previously_changed' => array(
          'description' => 'The Unix timestamp of the previous change.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'priority_override' => array(
          'description' => 'The priority of the term in the sitemap.',
          'type' => 'float',
          'not null' => TRUE,
          'default' => -2.0,
        ),
      ),
      'primary key' => array(
        'tid',
      ),
    ));
  }
  return $ret;
}