function hook_update

Handle needed database updates when user updates a module.

Modules can specify which schema their tables are using in their .info file. if the module, in a later version, changes the table it writes to, it should increment the schema number, whic causes the user to be notified (on the modules page) that they need to run the DB updates.

When the DB updates are run, every module implementing this function will be called (it is expected to be in a .install file, instead of the .module file, though both get included by the system first).

In this function, the developer can see what schema they are coming FROM, and make table or other alterations based on that information.

1 function implements hook_update()

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

system_update in modules/system/system.install

File

includes/hook.api.php, line 238
Lists all available hooks within FlightPath's core code.

Code

function hook_update($old_schema, $new_schema) {
  if ($new_schema < 4) {
    db_query("ALTER TABLE my_example_table ...... ");
  }
}