Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When updating to this version, I see the following in the Status Report:
"Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Vote Result
The Function field needs to be updated."
Which I've seen before. Normally, I would run "drush entity-updates". However, I have values in my field, and when I run this command, I get:
The following updates are pending:
vote_result entity type :
The Function field needs to be updated.
Do you wish to run all pending updates? (y/n): y
Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: The SQL storage cannot change the schema for an existing field (function in vote_result entity) with data. in [error]
Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->updateSharedTableSchema() (line 1434 of /app/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).
Failed: Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: !message in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->updateSharedTableSchema() (line 1434 of [error]
/app/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).
Any advice on what can be done other than deleting the fields and running drush entity-updates again?
Comment | File | Size | Author |
---|---|---|---|
#18 | 2947061.patch | 610 bytes | amme |
| |||
#6 | 0001-updating-function-field-size-from-50-to-100.patch | 1.98 KB | mwebaze |
Comments
Comment #2
andileco CreditAttribution: andileco at JSI Research & Training Institute, Inc. (JSI) commentedI thought this Sql command might take care of it, but it didn't:
ALTER TABLE votingapi_result MODIFY function VARCHAR(100);
Comment #3
Rop CreditAttribution: Rop as a volunteer commentedI have the exact same problem
Comment #4
pifagorWe can use
https://www.drupal.org/node/2641828#comment-10711058 or https://coderwall.com/p/uyidlq/updating-the-storage-definition-of-entiti... solutions.
Also you can add patch.
Patches are welcome
Comment #5
testii28 CreditAttribution: testii28 commentedI do have exactly the same problem. Even drush entity update doensn´t fix it.
Comment #6
mwebaze CreditAttribution: mwebaze as a volunteer and at JSI Research & Training Institute, Inc. (JSI) commented@Daniel and @testii28,
I have written a patch for this. Try it out and let me know. First back-up your database.
Regards,
Michael
Comment #7
testii28 CreditAttribution: testii28 commentedI would love to but no drush here :(
Comment #8
pifagorSpeak step by step how to reproduce the problem. If there is a test version of the code and the backup DB, you can give me so that I can reproduce the problems and correct it.
Comment #9
mwebaze CreditAttribution: mwebaze as a volunteer and at JSI Research & Training Institute, Inc. (JSI) commented@testii128 you can run update.php.
@Pifagor essentially what is happening is that Drupal will not update the entity 'vote_result' simply because it has data (storage handler) associated with it. The updated module's entity 'vote_result' has the BaseFieldDefinition settings for the 'function' field max_length changed from 50 to 100. Without any vote result data, Drupal automatically updates the entity however with data Drupal doesn't for obvious reasons.
Comment #10
andileco CreditAttribution: andileco at JSI Research & Training Institute, Inc. (JSI) commented@mwebaze this patch worked for me. Thanks!
Comment #11
pifagorComment #13
pifagorComment #14
pifagorComment #15
mattltHey everyone,
I'm getting the following error when running `drush updb` after this commit…
Let me know if you need any other information that might help track this down.
Thanks,
•• matt
Comment #16
andileco CreditAttribution: andileco at JSI Research & Training Institute, Inc. (JSI) commentedI had the following in my file earlier...not sure if they would help.
Comment #17
pifagorComment #18
amme CreditAttribution: amme commentedComment #19
amme CreditAttribution: amme commentedComment #20
mattltUsing the patch in #18 I was able to run the update successfully.
Thanks Amme!
•• matt
Comment #22
pifagorI corrected patch. Fixed coding standards.
Thanks for the patch.
Comment #23
pifagor