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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andileco created an issue. See original summary.

andileco’s picture

I thought this Sql command might take care of it, but it didn't:

ALTER TABLE votingapi_result MODIFY function VARCHAR(100);

Rop’s picture

I have the exact same problem

pifagor’s picture

Status: Active » Needs review
testii28’s picture

I do have exactly the same problem. Even drush entity update doensn´t fix it.

mwebaze’s picture

@Daniel and @testii28,

I have written a patch for this. Try it out and let me know. First back-up your database.

Regards,

Michael

testii28’s picture

I would love to but no drush here :(

pifagor’s picture

Status: Needs review » Needs work

Speak 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.

mwebaze’s picture

@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.

andileco’s picture

Status: Needs work » Reviewed & tested by the community

@mwebaze this patch worked for me. Thanks!

pifagor’s picture

  • pifagor committed 253e733 on 8.x-3.x authored by mwebaze
    Issue #2947061 by mwebaze, andileco, pifagor, testii28, rOprOprOp:...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed
pifagor’s picture

Status: Fixed » Closed (fixed)
mattlt’s picture

Hey everyone,

I'm getting the following error when running `drush updb` after this commit…

[error]  TypeError: Argument 1 passed to Drupal\Core\Database\Query\Insert::fields() must be of the type array, null given, called in /votingapi/votingapi.install on line 48 in Drupal\Core\Database\Query\Insert->fields() (line 70 of /core/lib/Drupal/Core/Database/Query/InsertTrait.php) #0 /votingapi/votingapi.install(48): Drupal\Core\Database\Query\Insert->fields(NULL)

Let me know if you need any other information that might help track this down.

Thanks,

•• matt

andileco’s picture

I had the following in my file earlier...not sure if they would help.

use Drupal\Core\Database\Database;
use Drupal\field\Entity\FieldStorageConfig;
pifagor’s picture

Status: Closed (fixed) » Needs work
amme’s picture

FileSize
610 bytes
amme’s picture

Status: Needs work » Needs review
mattlt’s picture

Using the patch in #18 I was able to run the update successfully.

Thanks Amme!

•• matt

  • pifagor committed 0079dbe on 8.x-3.x
    Issue #2947061 by mwebaze, amme, pifagor, andileco, mattlt, testii28,...
pifagor’s picture

Status: Needs review » Fixed

I corrected patch. Fixed coding standards.
Thanks for the patch.

pifagor’s picture

Status: Fixed » Closed (fixed)