You are here

function xmlsitemap_update_6198 in XML sitemap 6.2

Upgrade the {xmlsitemap} table (drop and re-create).

File

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

Code

function xmlsitemap_update_6198() {
  $ret = array();
  if (db_column_exists('xmlsitemap', 'sid')) {
    db_drop_table($ret, 'xmlsitemap');
    $schema['xmlsitemap'] = array(
      'description' => 'The base table for xmlsitemap links.',
      'fields' => array(
        'id' => array(
          'description' => 'Primary key with type; a unique id for the item.',
          'type' => 'int',
          'not null' => TRUE,
          'unsigned' => TRUE,
          'default' => 0,
        ),
        'type' => array(
          'description' => 'Primary key with id; the type of item (e.g. node, user, etc.).',
          'type' => 'varchar',
          'length' => 32,
          'not null' => TRUE,
          'default' => '',
        ),
        'subtype' => array(
          'description' => 'A sub-type identifier for the link (node type, menu name, term VID, etc.).',
          'type' => 'varchar',
          'length' => 128,
          'not null' => TRUE,
          'default' => '',
        ),
        'loc' => array(
          'description' => 'The URL to the item relative to the Drupal path.',
          'type' => 'varchar',
          'length' => 255,
          'not null' => TRUE,
          'default' => '',
        ),
        'language' => array(
          'description' => 'The {languages}.language of this link or an empty string if it is language-neutral.',
          'type' => 'varchar',
          'length' => 12,
          'not null' => TRUE,
          'default' => '',
        ),
        'access' => array(
          'description' => 'A boolean that represents if the item is viewable by the anonymous user. This field is useful to store the result of node_access() so we can retain changefreq and priority_override information.',
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'default' => 1,
        ),
        'status' => array(
          'description' => 'An integer that represents if the item is included in the sitemap.',
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'default' => 1,
        ),
        'status_override' => array(
          'description' => 'A boolean that if TRUE means that the status field has been overridden from its default value.',
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'default' => 0,
        ),
        'lastmod' => array(
          'description' => 'The UNIX timestamp of last modification of the item.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'priority' => array(
          'description' => 'The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0.',
          'type' => 'float',
          'default' => NULL,
        ),
        'priority_override' => array(
          'description' => 'A boolean that if TRUE means that the priority field has been overridden from its default value.',
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'default' => 0,
        ),
        'changefreq' => array(
          'description' => 'The average time in seconds between changes of this item.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'changecount' => array(
          'description' => 'The number of times this item has been changed. Used to help calculate the next changefreq value.',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
      ),
      'primary key' => array(
        'id',
        'type',
      ),
      'indexes' => array(
        'loc' => array(
          'loc',
        ),
        'access_status_loc' => array(
          'access',
          'status',
          'loc',
        ),
        'type_subtype' => array(
          'type',
          'subtype',
        ),
        'language' => array(
          'language',
        ),
      ),
    );
    db_create_table($ret, 'xmlsitemap', $schema['xmlsitemap']);
    db_query("INSERT INTO {xmlsitemap} (type, id, loc, priority, changefreq) VALUES ('frontpage', 0, '', %f, %d)", variable_get('xmlsitemap_frontpage_priority', 1.0), variable_get('xmlsitemap_frontpage_changefreq', 86400));

    // Force a rebuild for table schemas.
    drupal_get_schema(NULL, TRUE);
  }
  return $ret;
}