When reverting a feature that contains a relation field, I get the following error. Please note that this is using an up-do-date repository, with update 7001 having run.

[jpathan@drupal-qa-jnl-web02 drupal-webroot]$ drush fr highwire -y
Do you really want to revert field? (y/n): y
WD php: DatabaseSchemaObjectExistsException: Cannot add index endpoints_entity_id to table field_data_endpoints: index       [error]
already exists. in DatabaseSchema_mysql->addIndex() (line 443 of
/opt/sites/jnl-ajpheart-testing/drupal-webroot/includes/database/mysql/schema.inc).
Cannot modify header information - headers already sent by (output started at                                              [warning]
/usr/share/pear/drush/includes/output.inc:38) bootstrap.inc:1440
DatabaseSchemaObjectExistsException: Cannot add index endpoints_entity_id to table field_data_endpoints: index already exists. in DatabaseSchema_mysql->addIndex() (line 443 of /opt/sites/jnl-ajpheart-testing/drupal-webroot/includes/database/mysql/schema.inc).
Drush command terminated abnormally due to an unrecoverable error.                                                           [error]

Under investigation, it appears that it is because the indexes in the database are in a different order than the indexes in the schema, resulting in field-api thinking the schema is out-of-date and tries to add the indexes, resulting in an error.

CommentFileSizeAuthor
#2 relation.2555611.2.patch1.7 KBphayes

Comments

phayes created an issue. See original summary.

phayes’s picture

Status: Active » Needs review
StatusFileSize
new1.7 KB

Attached is a patch that fixes this issue.

derhasi’s picture

mikran’s picture

@phayes does the core patch fix your problem?

Your patch is re-adding indexes the same way as the original update hook did so I fear that it might not even fix the real issue here.

possibri’s picture

I'm also experiencing this issue, and the provided patch definitely doesn't work. Anybody have any idea how to fix this? If I can get pointed in the right direction I can probably figure it out, but I honestly don't even know where to begin. Thanks!

scuba_fly’s picture

Status: Needs review » Reviewed & tested by the community

Combined with the core patch https://www.drupal.org/node/2003746#2 I got rid of this error.

possibri’s picture

Thanks @scuba_fly! I can confirm that implementing this with the core patch indeed solves the issue.

jfhovinne’s picture

I had the exact same issue, and also confirm #6.

mikran’s picture

Status: Reviewed & tested by the community » Postponed