1 system.api.php 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.

Note that when a module is installed, schema alterations are not applied (see backdrop_install_schema()), so it should also implement hook_install() (and possibly hook_uninstall()) to perform the alterations there. See comment.install for an example.

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


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

Related topics


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


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.',