Problem/Motivation

I've recently inherited an OA site that hasn't been updated for literally years - it's still running 2.12. I want to update it to the latest version of OA, primarily for all the security fixes.

However I'm getting stuck preparing for the upgrade, even before modifying the codebase.

There are a lot of overridden features, so I followed the instructions to create a new features override feature to capture them all. However upon enabling it, a number of errors were displayed. So I restored by database backup and started again.

This time I took a different approach - I assumed that all the overrides can be lost, so instead of creating a new features override feature and enabling it, this time I simply chose to revert all the existing features using drush -y fra. To clarify, I do want to capture the customisations so that they don't have to be manually re-applied after the update (so will want to come back to this eventually), but by overlooking it for now we rule out any errors with my newly created feature, and are purely finding errors with the existing features/database.

It fails pretty quickly:

drush -y fra
The following modules will be reverted: panopoly_widgets, command_buttons, panopoly_search, oa_sections, trash_flag, oa_buttons, oa_config, oa_messages, oa_discussion, oa_layouts, oa_events, oa_events_import, oa_favorites, oa_home, oa_media, panopoly_users, oa_panopoly_users, oa_wiki, panopoly_wysiwyg, oa_search, oa_users, oa_worktracker, panopoly_images, panopoly_pages, panels_customerror

exception 'DatabaseSchemaObjectExistsException' with message 'Table <em class="placeholder">field_data_field_map_address</em> already exists.' in /app/www/includes/database/schema.inc:657      
Stack trace:
#0 /app/www/includes/database/database.inc(2717): DatabaseSchema->createTable('field_data_fiel...', Array)
#1 /app/www/modules/field/modules/field_sql_storage/field_sql_storage.module(216): db_create_table('field_data_fiel...', Array)
#2 [internal function]: field_sql_storage_field_storage_create_field(Array)
#3 /app/www/includes/module.inc(866): call_user_func_array('field_sql_stora...', Array)
#4 /app/www/modules/field/field.crud.inc(180): module_invoke('field_sql_stora...', 'field_storage_c...', Array)
#5 /app/www/profiles/openatrium/modules/contrib/features/includes/features.field.inc(268): field_create_field(Array)
#6 /app/www/profiles/openatrium/modules/contrib/features/includes/features.field.inc(237): field_base_features_rebuild('panopoly_widget...')
#7 [internal function]: field_base_features_revert('panopoly_widget...', 'field_base')
#8 /app/www/profiles/openatrium/modules/contrib/features/features.module(562): call_user_func_array('field_base_feat...', Array)
#9 /app/www/profiles/openatrium/modules/contrib/features/features.module(945): features_invoke('field_base', 'features_revert', 'panopoly_widget...')
#10 /app/www/profiles/openatrium/modules/contrib/features/features.module(964): _features_restore('revert', Array)
#11 /app/www/profiles/openatrium/modules/contrib/features/features.drush.inc(728): features_revert(Array)
#12 [internal function]: drush_features_revert('panopoly_widget...', 'command_buttons', 'panopoly_search', 'oa_sections', 'trash_flag', 'oa_buttons', 'oa_config', 'oa_messages', 'oa_discussion', 'oa_layouts', 'oa_events', 'oa_events_impor...',
'oa_favorites', 'oa_home', 'oa_media', 'panopoly_users', 'oa_panopoly_use...', 'oa_wiki', 'panopoly_wysiwy...', 'oa_search', 'oa_users', 'oa_worktracker', 'panopoly_images', 'panopoly_pages', 'panels_customer...')
#13 /var/www/.composer/vendor/drush/drush/includes/command.inc(361): call_user_func_array('drush_features_...', Array)
#14 /var/www/.composer/vendor/drush/drush/includes/command.inc(212): _drush_invoke_hooks(Array, Array)
     

I checked in the database, and yes, field_data_field_map_address does exist and it has 7 rows.
I try running drush -y fra again, this time it seems to make more progress:

The following modules will be reverted: command_buttons, panopoly_search, oa_sections, trash_flag, oa_buttons, oa_config, oa_messages, oa_discussion, oa_layouts, oa_events, oa_events_import, oa_favorites, oa_home, oa_media, oa_notifications, panopoly_users, oa_panopoly_users, oa_wiki, panopoly_wysiwyg, oa_search, oa_users, oa_worktracker, panopoly_images, panopoly_pages, panels_customerror
Do you really want to continue? (y/n): y
Reverted command_buttons.field_group.                                                                                                                                                                                                                [ok]
Reverted panopoly_search.search_api_index.                                                                                                                                                                                                           [ok]
Reverted panopoly_search.search_api_server.                                                                                                                                                                                                          [ok]
Reverted panopoly_search.variable.                                                                                                                                                                                                                   [ok]
Reverted panopoly_search.views_view.                                                                                                                                                                                                                 [ok]
Reverted oa_sections.field_group.                                                                                                                                                                                                                    [ok]
Reverted oa_sections.variable.                                                                                                                                                                                                                       [ok]
Reverted trash_flag.flag.                                                                                                                                                                                                                            [ok]
exception 'DatabaseSchemaObjectExistsException' with message 'Table <em class="placeholder">field_data_field_oa_section_layout</em> already exists.' in /app/www/includes/database/schema.inc:657                                                    [error]
Stack trace:
#0 /app/www/includes/database/database.inc(2717): DatabaseSchema->createTable('field_data_fiel...', Array)
#1 /app/www/modules/field/modules/field_sql_storage/field_sql_storage.module(216): db_create_table('field_data_fiel...', Array)
#2 [internal function]: field_sql_storage_field_storage_create_field(Array)
#3 /app/www/includes/module.inc(866): call_user_func_array('field_sql_stora...', Array)
#4 /app/www/modules/field/field.crud.inc(180): module_invoke('field_sql_stora...', 'field_storage_c...', Array)
#5 /app/www/profiles/openatrium/modules/contrib/features/includes/features.field.inc(268): field_create_field(Array)
#6 /app/www/profiles/openatrium/modules/contrib/features/includes/features.field.inc(237): field_base_features_rebuild('oa_buttons')
#7 [internal function]: field_base_features_revert('oa_buttons', 'field_base')
#8 /app/www/profiles/openatrium/modules/contrib/features/features.module(562): call_user_func_array('field_base_feat...', Array)
#9 /app/www/profiles/openatrium/modules/contrib/features/features.module(945): features_invoke('field_base', 'features_revert', 'oa_buttons')
#10 /app/www/profiles/openatrium/modules/contrib/features/features.module(964): _features_restore('revert', Array)
#11 /app/www/profiles/openatrium/modules/contrib/features/features.drush.inc(728): features_revert(Array)
<snip>

So similar error, different table. I check the DB and field_data_field_oa_section_layout exists but there are no rows in it, so I run a SQL query to drop it: DROP TABLE field_data_field_oa_section_layout;

Then I try drush -y fra again:

The following modules will be reverted: panopoly_search, oa_buttons, oa_config, oa_messages, oa_discussion, oa_layouts, oa_events, oa_events_import, oa_favorites, oa_home, oa_media, oa_notifications, panopoly_users, oa_panopoly_users, oa_wiki, panopoly_wysiwyg, oa_search, oa_users, oa_worktracker, panopoly_images, panopoly_pages, panels_customerror
Do you really want to continue? (y/n): y
Reverted panopoly_search.search_api_index.                                                                                                                                                                                                           [ok]
exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal7.field_data_field_oa_section' doesn't exist' in /app/www/includes/database/database.inc:2168    
Stack trace:
#0 /app/www/includes/database/database.inc(2168): PDOStatement->execute(Array)
#1 /app/www/includes/database/database.inc(680): DatabaseStatementBase->execute(Array, Array)
#2 /app/www/includes/database/select.inc(1264): DatabaseConnection->query('SELECT COUNT(*)...', Array, Array)
#3 /app/www/includes/entity.inc(1313): SelectQuery->execute()
#4 /app/www/modules/field/modules/field_sql_storage/field_sql_storage.module(585): EntityFieldQuery->finishQuery(Object(SelectQuery), 'entity_id')
#5 [internal function]: field_sql_storage_field_storage_query(Object(EntityFieldQuery))
#6 /app/www/includes/entity.inc(1140): call_user_func('field_sql_stora...', Object(EntityFieldQuery))
#7 /app/www/modules/field/field.module(958): EntityFieldQuery->execute()
#8 /app/www/modules/field/field.crud.inc(259): field_has_data(Array)
#9 /app/www/profiles/openatrium/modules/contrib/features/includes/features.field.inc(264): field_update_field(Array)
#10 /app/www/profiles/openatrium/modules/contrib/features/includes/features.field.inc(237): field_base_features_rebuild('oa_buttons')
#11 [internal function]: field_base_features_revert('oa_buttons', 'field_base')
#12 /app/www/profiles/openatrium/modules/contrib/features/features.module(562): call_user_func_array('field_base_feat...', Array)
#13 /app/www/profiles/openatrium/modules/contrib/features/features.module(945): features_invoke('field_base', 'features_revert', 'oa_buttons')
#14 /app/www/profiles/openatrium/modules/contrib/features/features.module(964): _features_restore('revert', Array)
<snip>

Should I be approaching this in a different way?
Any advice gratefully received, thanks.

Comments

nicrodgers created an issue. See original summary.

nicrodgers’s picture

Issue summary: View changes
nicrodgers’s picture

Title: Updating from OA 2.12 » Updating from OA 2.12 - "Table already exists" errors when trying to revert features