There is a site where I started to use the beta 5 version of field_collection and after a while a update for dev version. I ran the new hook_updates and created the index for exist tables.
I want to add the fields to feature and when I want to revert it I got the next error:
"DatabaseSchemaObjectExistsException: Cannot add index field_consulting_rooms_revision_id to table field_data_field_consulting_rooms: index already exists. in DatabaseSchema_mysql->addIndex() (line 437 of /var/www/pszichologuskereso/includes/database/mysql/schema.inc)."
I found that, the feature don't know from index, so the feature want to create the index again.
I found that, the index update wasn't proper because the field info didn't know about the index. So, I wrote a patch, which changed the 7004 update.
Comments
Comment #1
segi CreditAttribution: segi commentedComment #3
segi CreditAttribution: segi commentedSorry, for wrong patch.
Comment #5
segi CreditAttribution: segi commentedComment #6
yaoweizhen CreditAttribution: yaoweizhen commentedI also have this error. The patch is fixed.
Comment #7
Jody LynnMy fields were already in features and when the update broke the site with this error I had to run this script to fix it:
Presumably this situation would not have occurred with the patch from 5 applied before I ran the update.
Comment #8
Dane Powell CreditAttribution: Dane Powell commentedThanks everyone for the patches and tips!
I can confirm this is a bug, and that patch in #5 prevents it. Also, the script in #7 is great for fixing it after the fact.
Attached is the same script in drush-script format. For anyone not familiar...
chmod +x ./fix-fields.drush
)./fix-fields.drush @default
to fix your db (replace @default with your site alias, if necessary)Comment #9
dmsmidtJust a humble thanks for #7 :-)
Comment #10
deviantintegral CreditAttribution: deviantintegral commentedThe patch in #5 is working fine for me as well.
Given that this could be broken for sites that already tried to upgrade, I wonder if the drush script from #8 should be integrated into an update hook as well?
Comment #11
q0rban CreditAttribution: q0rban commentedHere's an example update hook one might use to fix this on their site:
Comment #12
jstollerI rolled a new patch combining segi's patch from #5 with q0rban's update function from #11. After applying this patch and running drush updb my problem seems to have been fixed.
Comment #13
colanAgreed.
Comment #14
Yuri CreditAttribution: Yuri commentedI tested the patch in #12 and it removes the error message, but in my case something is not saved to the database correctly..I think.
I use the multiple value widget for a field collection field. The error appeared when I tried to save the field collection field settings.
After the patch, I can save it, but the multiple value widget settings are not applied to the field collection.
I uninstalled and reinstalled the multiple value widget module, but still the same. So I think something is still not working in this patch.
Comment #15
fagoWhat's that for? Should be commented as unclear.
Should use field_read_fields as above?
Comment #16
bdone CreditAttribution: bdone commentedis this patch any simplier?
this allowed me to run field_collection_update_7004(), after changing from dev to 1.0-beta7, where i had already ran this update.
Comment #17
bdone CreditAttribution: bdone commentedremove extra argument from patch in #2141781-16: Existing index issue with revision_id index.
Comment #18
bdone CreditAttribution: bdone commentedComment #19
azathot CreditAttribution: azathot commentedThe patch in #12 appears to be working well for me.
Comment #20
juampynr CreditAttribution: juampynr commentedCan't we just check before adding the index? For failed upgrades, the indexes may have been added already.
Comment #21
wipeout_dude CreditAttribution: wipeout_dude commentedHi,
After upgrading from Beta4 to Beta7 I have some issues, one of them was not being able to modify the field properties..
fix-fields.drush has allowed me to edit the field properties again which is great, but not resolved main problem of not being able to create new nodes with field collections..
Anyway.. Reason for this post is to say that the script doesn't work if you have a database table prefix so this had to be added to the two "field_config" references in the script..
Comment #22
capellicThe patch in #12 by @jstoller is what did it for me. I had a site that has been working on beta5 just fine for many, many months. But then when I wanted to update the field collection field, I got the error that an attempt to add the index failed due to it already being on the field. I thought it odd because I wasn't running update at the time, just updating a field.
Only the patch in #12 fixes my issue due to me having an existing install of beta5 versus trying to upgrade from a previous version. The code in field_collection_update_7005() was critical for me and this patch is the only one that has that.
I have tested the ability to make changes to the field collection field and all seems to be working fine. Thanks!
Comment #23
sinasalek CreditAttribution: sinasalek commentedI applied #20 patch and it fixed the main issue but had to use the code mentioned in #7 to fix it
for existing fields after the upgrade
However it think that a new update should be included in the next release to automatically fix the issue, therefore the code mentioned in #7 can be included as update_7005
Comment #24
sinasalek CreditAttribution: sinasalek commentedComment #25
juampynr CreditAttribution: juampynr commentedHere I am combining patches #12 and #20. It addresses the following scenarios outlined in the thread:
Comment #26
JonMcL CreditAttribution: JonMcL commentedPatch at #25 worked well for me.
Comment #27
jstollerThe only difference between this patch and #25 is that I've moved the new update function to field_collection_update_7006(), since field_collection_update_7005() has already been committed to dev. I'm also bumping the priority, since I can't update my sites without a constant error until this patch gets in, and I can't deploy this patch myself, for fear that a different #7006 update function will be committed first.
I've tested this patch both by doing a fresh update, and by fixing an update that had already been performed using the existing dev release. Both cases worked perfectly, with no more errors.
Comment #28
jstollerGiven #27 is just a minor re-roll and #25 was working for people, I'm marking this RTBC. Feel free to change it back if you think that is premature.
Comment #29
Itangalo CreditAttribution: Itangalo commentedPatch in #27 worked fine for me. +1 for committing.
Comment #30
apemantus CreditAttribution: apemantus commentedWorks for me and needed this patch quite significantly.
Comment #32
jmuzz CreditAttribution: jmuzz commentedThanks all.
Comment #34
soliyappan CreditAttribution: soliyappan commentedPatch #25 worked well for me.
Comment #35
jaxpax CreditAttribution: jaxpax commentedPatch #25 worked well for me.
Comment #36
JvE CreditAttribution: JvE commentedComment #37
Countzero CreditAttribution: Countzero commented#25 did the trick. Thanks.
Comment #38
manishmore CreditAttribution: manishmore as a volunteer and commentedHi
To work it out the https://www.drupal.org/node/2141781 with latest version of 7.x-1.0-beta11 for field_collection module. have updated the patch.