function hook_schema_alter

7.x system.api.php hook_schema_alter(&$schema)
6.x core.php hook_schema_alter(&$schema)

Performs 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.

Return value

None.

Related topics

1 invocation of hook_schema_alter()
drupal_get_schema in drupal-6.x/includes/common.inc
Get the schema definition of a table, or the whole database schema.

File

documentation-6.x/developer/hooks/core.php, line 725
These are the hooks that are invoked by the Drupal core.

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.',
  );
}