Hello,
I've just discovered a weird bug in my workbench moderation module, where the schema version is set to -1 despite the module being enabled.
This has resulted in none of the module's database updates running.
I'm not sure whether this is a bug in how the site I'm working on has been set up, or something in the module itself, but it was easily enough fixed in a small update script in a custom module; if this issue has affected other users, maybe this check could be incorporated into the module's hook_init(), so that the next time the database is updated the schema updates can run correctly?
Hopefully this will help somebody else experiencing weird errors like me :)
For example...
function workbench_moderation_init() {
/**
* Change schema version of workbench moderation module to 0 if it's
* -1 - otherwise, schema updates will not run and we will encounter fatal DB
* errors, e.g. missing column "is_current". :(
*
* Note: you will need to run the database updates script to catch any
* remaining updates.
*/
if (!variable_get('workbench_moderation_schema_check', FALSE)) {
db_update('system')
->fields(array('schema_version' => 0))
->condition('name', 'workbench_moderation')
->condition('schema_version', -1)
->condition('status', 1)
->execute();
variable_set('workbench_moderation_schema_check', TRUE);
}
This resulted in the following Drush output when I re-ran drush updatedb:
Cs_settings 7102 Change schema version of workbench moderation module to 0 if it's -1 - otherwise, schema updates will not run and we
will encounter fatal DB errors, e.g. missing column "is_current". :( Note: you will need to re-run the database
updates script to catch any remaining updates.
Do you wish to run all pending updates? (y/n): y
Changed schema version of workbench moderation module to 0 if it's -1 - otherwise, schema updates will not run and we will [ok]
encounter fatal DB errors, e.g. missing column "is_current". :( Note: you will need to re-run the database updates script to catch
any remaining updates.
Performed update: cs_settings_update_7102 [ok]
'all' cache was cleared. [success]
Finished performing updates. [ok]
Workbench_moderation 7001 Update the 'weight' field on {workbench_moderation_states}. Accept standard Drupal weight values.
Workbench_moderation 7002 Drop the unused 'ntypes' field from workbench_moderation_transitions.
Workbench_moderation 7003 Use "revision" instead of "version" when referring to node revisions.
Workbench_moderation 7004 Use "Published" instead of "Publish" and "Needs Review" instead of "Review" for state names.
Workbench_moderation 7005 Shorten descriptions for default states
Workbench_moderation 7006 Add machine names to moderation states.
Workbench_moderation 7007 Replace the "Unpublish the current live revision" permission with a transition.
Workbench_moderation 7008 Fix the not null column schema for {workbench_moderation_states}.name.
Workbench_moderation 7009 Add new fields to workbench_moderation_transitions table.
Workbench_moderation 7010 Comply with SQL-99: Rename the 'current' column to 'is_current'.
Do you wish to run all pending updates? (y/n): y
Updated the weight field on the moderation states table. [ok]
Performed update: workbench_moderation_update_7001 [ok]
Dropped unused field from the moderation transitions table. [ok]
Performed update: workbench_moderation_update_7002 [ok]
The renamed permission was updated for 0 roles. [ok]
Performed update: workbench_moderation_update_7003 [ok]
Updated state names and transitions. [ok]
Performed update: workbench_moderation_update_7004 [ok]
Updated state descriptions. [ok]
Performed update: workbench_moderation_update_7005 [ok]
Cannot add field workbench_moderation_states.label: field already exists. [error]
Performed update: workbench_moderation_update_7006 [ok]
'all' cache was cleared. [success]
Finished performing updates. [ok]
Comments