You are here

function nodeorder_install in Node Order 7

Same name and namespace in other branches
  1. 8 nodeorder.install \nodeorder_install()
  2. 5 nodeorder.install \nodeorder_install()
  3. 6 nodeorder.install \nodeorder_install()

Implements hook_install().

Adds field 'weight' to core table 'taxonomy_index'. @todo: Handle exceptions that could be thrown by DatabaseSchema::addField.

File

./nodeorder.install, line 14
Nodeorder install file.

Code

function nodeorder_install() {

  // Define field properties.
  $schema = drupal_get_schema('taxonomy_index');
  $spec = $schema['fields']['weight'];

  // Create an index for 'weight'
  $keys['indexes'] = array(
    'weight' => array(
      'weight',
    ),
  );

  // Add the column to the table.
  db_add_field('taxonomy_index', 'weight', $spec, $keys);

  // Set the weight of the nodeorder module in the system table to ensure that
  // nodeorder can alter forms after the taxonomy module.
  db_update('system')
    ->fields(array(
    'weight' => 5,
  ))
    ->condition('name', 'nodeorder')
    ->condition('type', 'module')
    ->execute();
}