You are here

function pathauto_update_7006 in Pathauto 7

Create pathauto_state table, using data from pathauto_persist if it exists.

File

./pathauto.install, line 231
Install, update, and uninstall functions for Pathauto.

Code

function pathauto_update_7006() {
  if (!db_table_exists('pathauto_state')) {
    $schema['pathauto_state'] = array(
      'description' => 'The status of each entity alias (whether it was automatically generated or not).',
      'fields' => array(
        'entity_type' => array(
          'type' => 'varchar',
          'length' => 32,
          'not null' => TRUE,
          'description' => 'The entity type.',
        ),
        'entity_id' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'description' => 'The entity ID.',
        ),
        'pathauto' => array(
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'default' => 0,
          'description' => 'The automatic alias status of the entity.',
        ),
      ),
      'primary key' => array(
        'entity_type',
        'entity_id',
      ),
    );
    if (db_table_exists('pathauto_persist')) {

      // Rename pathauto_persist's table, then create a new empty one just so
      // that we can cleanly disable that module.
      db_rename_table('pathauto_persist', 'pathauto_state');
      db_create_table('pathauto_persist', $schema['pathauto_state']);

      // Disable the module and inform the user.
      if (module_exists('pathauto_persist')) {
        module_disable(array(
          'pathauto_persist',
        ));
      }
      return t('The Pathauto Persist module and all of its data has been merged into Pathauto. The Pathauto Persist module has been disabled and can be safely uninstalled.');
    }
    else {
      db_create_table('pathauto_state', $schema['pathauto_state']);
    }
  }
}