function workflow_update_7015 in Workflow 7.2
Add database fields. Make Workflow entity-aware, exportable.
File
- ./
workflow.install, line 727 - Install, update and uninstall functions for the workflow module.
Code
function workflow_update_7015() {
$schema = workflow_schema();
// Update the Workflow table.
$table = 'workflows';
$fields = $schema[$table]['fields'];
if (!db_field_exists($table, 'label')) {
db_add_field($table, 'label', $fields['label']);
}
if (!db_field_exists($table, 'status')) {
db_add_field($table, 'status', $fields['status']);
}
if (!db_field_exists($table, 'module')) {
db_add_field($table, 'module', $fields['module']);
}
// Update the WorkflowConfigTransitions table.
$table = 'workflow_transitions';
$fields = $schema[$table]['fields'];
if (!db_field_exists($table, 'label')) {
db_add_field($table, 'label', $fields['label']);
}
if (!db_field_exists($table, 'name')) {
db_add_field($table, 'name', $fields['name']);
}
// Update the WorkflowStates table.
$table = 'workflow_states';
$fields = $schema[$table]['fields'];
if (!db_field_exists($table, 'name')) {
db_add_field($table, 'name', $fields['name']);
}
// Update the WorkflowHistory table.
$table = 'workflow_node_history';
$fields = $schema[$table]['fields'];
// This is moved from hook_update_7008().
if (!db_field_exists($table, 'revision_id')) {
db_add_field($table, 'revision_id', $fields['revision_id']);
}
// Load&save workflows, to populate the label.
// Do this after all db-updates!!
// Do not use workflow_*() functions.
foreach (entity_load('Workflow') as $workflow) {
$workflow
->save();
// Load&save workflow states, to populate the state name.
foreach ($workflow
->getStates(TRUE, TRUE) as $state) {
$state
->save();
}
}
// The update system is going to flush all caches,
// including the updated Rules Action, so nothing to do here.
}