When updating the votingapi module to version 8.x-3.0-beta1. I had the problem of not being able to update the vote_result entity.

I used the command "drush entup" but got the error "The SQL storage cannot change the schema for an existing field (function in vote_result entity) with data."

And the way below has helped me solve that problem. Hope it can be helpful.

Note: Back up your database first.
Step 1: Export the votingapi_result table and the votingapi_vote tables into the corresponding sql files. I use the command line "mysqldump -uSqluser -p mysitedb votingapi_vote > votingapi_vote.sql" and "mysqldump -uSqluser -p mysitedb votingapi_result > votingapi_result.sql".
Step 2: Export all configurations. Here I use the command line: "drush cex".
Step 3: Uninstall votingapi module, in this step, rate module will also be required to uninstall.
Step 4: Import the exported configuration in step 2. I use the command line: "drush cim".
Step 5: Import the votingapi_result data table and the votingapi_vote data table exported in step 1. Note that you need to edit the xxx.sql file and delete the table creation for "Table structure for table `xxx`"
because this table already exists, we only need to keep "Dumping data for table `xxx`" because these are the data that needs to be re-imported. I use the command line: "drush sql:cli < votingapi_vote.sql" and "drush sql:cli < votingapi_result.sql".
Step 6: Clear the cache and see the results.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bcmc0904 created an issue. See original summary.

bcmc0904’s picture

Issue summary: View changes
manishdrupaldev’s picture

I have applied all the steps as per given above.
It's working for me.
Thanks for update.

a.dmitriiev’s picture

Here is the patch with update hook for proper change of the field definition that fixes the issue.

a.dmitriiev’s picture

Status: Active » Needs review
a.dmitriiev’s picture

I found that the previous patch is not working for the case when there is already data in the database table. So here is another patch that works in any case.

andralex’s picture

Status: Needs review » Reviewed & tested by the community

Tested localy and did't faced any issue.

alex_optim’s picture

+1

pifagor’s picture

  • pifagor committed 12f810d on 8.x-3.x authored by a.dmitriiev
    Issue #3083473 by a.dmitriiev, bcmc0904, alex_optim, manishdrupaldev,...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.