function hook_schema_alter

hook_schema_alter(&$schema)

Perform alterations to existing database schemas.

When a module modifies the database structure of another module (by changing, adding or removing fields, keys or indexes), it should implement hook_schema_alter() to update the default $schema to take its changes into account.

See hook_schema() for details on the schema definition structure.

Parameters

$schema: Nested array describing the schemas for all modules.

Related topics

File

modules/system/system.api.php, line 3278
Hooks provided by Drupal core and the System module.

Code

function hook_schema_alter(&$schema) {
  // Add field to existing schema.
  $schema['users']['fields']['timezone_id'] = array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'description' => 'Per-user timezone configuration.',
  );
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_schema_alter/7.x