function hook_schema_alter

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

1 function implements hook_schema_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_test_schema_alter_field_schema_alter in modules/field/tests/field_test_schema_alter.install
Implements hook_field_schema_alter().
1 invocation of hook_schema_alter()
drupal_get_complete_schema in includes/bootstrap.inc
Gets the whole database schema.

File

modules/system/system.api.php, line 3294

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.