function workbench_workflows_db_update in Workbench Moderation 7.2
Helper to do db updates.
Supported actions based on the schema hook:
- Add new tables
- Add new fields
- Drop tables
Parameters
string $table: The name of the table to update.
2 calls to workbench_workflows_db_update()
- workbench_workflows_update_7000 in modules/
workbench_workflows/ workbench_workflows.install - Add new fields for state and event plugin to support event scheduling.
- workbench_workflows_update_7001 in modules/
workbench_workflows/ workbench_workflows.install - Add new fields for workflow to have default state per workflows.
File
- modules/
workbench_workflows/ workbench_workflows.install, line 251 - Database functions for workbench_workflows.
Code
function workbench_workflows_db_update($table) {
$schema = workbench_workflows_schema();
// If schema contains requested table handle it, else drop it.
if (isset($schema[$table])) {
// If table exists check existing items, else create table.
if (db_table_exists($table)) {
if (isset($schema[$table]['fields'])) {
foreach ($schema[$table]['fields'] as $field => $field_schema) {
if (!db_field_exists($table, $field)) {
db_add_field($table, $field, $field_schema);
}
}
}
}
else {
db_create_table($table, $schema[$table]);
}
}
elseif (db_table_exists($table)) {
db_drop_table($table);
}
}