function hook_update
Search API
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.
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- alerts_update in modules/
alerts/ alerts.install - announcements_update in modules/
announcements/ announcements.install - calendar_update in modules/
calendar/ calendar.install - content_update in modules/
content/ content.install - course_search_update in modules/
course_search/ course_search.install - Implements hook_update
File
- includes/
hook.api.php, line 535 - 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 ...... ");
}
}