I have Drupal 8 installed beginning of RC1 and afterward upgraded successfully up to 8.0. The status report page from the very first version is displaying:

Entity/field definitions Mismatch detected
Mismatched entity and/or field definitions.

Currently I have some common extensions installed but at the beginning the error was displayed even in the core.

My webpage is in polish language.

I was trying to install drush tu update entities but can't get it working properly (http://drupal.stackexchange.com/questions/179201/command-entity-updates-...).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Abdel5 created an issue. See original summary.

marcingy’s picture

Abdel5’s picture

Status: Closed (duplicate) » Active

I reopen this as the issue marked as duplicate was fixed and in my case the problem persists after upgrade to Drupal 8 RC 4.

Abdel5’s picture

Version: 8.0.0-rc2 » 8.0.0

I have the same error after upgrade to D8.

cilefen’s picture

Version: 8.0.0 » 8.0.x-dev

@Abdel5 Could you please enhance the issue summary with any more information you have on the issue, such as what action triggers the error?

Abdel5’s picture

Issue summary: View changes
Abdel5’s picture

Issue summary: View changes
enginpost’s picture

Version: 8.0.x-dev » 8.0.1
Component: update.module » entity system
FileSize
62.07 KB

After installing pathauto and token into drupal core 8.0.0 and upgrading to 8.0.1 I started getting the error depicted in the attached image:

Entity/field definitions Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.

Content
Delete the URL alias field.

Taxonomy term
Delete the URL alias field.

Is this a bug? Is it related? I have no idea how to fix this.

image of error

JotaMG’s picture

Me too, after upgrading from 8.0.1 to 8.0.2...
So, same questions as post above...???

Abdel5’s picture

Hi. in my case the error is in http://uzbrojeni.pl/admin/reports/status is currently:

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Komentarz

Update the comment.comment_body field.

Wilfred Waltman’s picture

I used "drush entity-updates" to fix the errors I had.

petiar’s picture

I have the same error in the status report, but I do not have drush - is there any way how to do the "entity-updates" via UI?

cilefen’s picture

I think visiting /update.php would do it but I could be mistaken.

TheThemerist’s picture

Same error message as enginpost in #8
After installing pathauto (8.x-1.0-alpha1) and token (8.x-1.0-alpha2) on Drupal 8.0.2
Have cleared cache, rebuilt and update.php to no avail.
'drush entity-updates' results in 'Drush was not able to start (bootstrap) the Drupal[error]
database' error. - I'm working on MAMP atm, so that's probably another can of php worms

Abdel5’s picture

Visting update page does not help and in my case drush was not working either.

john.oltman’s picture

drush entity-updates worked for me as well.

For themeninja:

If you are on MAMP, look at these articles, adjusting the paths for your version of MAMP and PHP.

http://drupal.stackexchange.com/questions/96803/drush-db-connection-on-mamp
http://drupal.stackexchange.com/questions/32402/drush-and-mysql-database...

For the latter, probably just need this one added to your bash profile:
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.4.4/bin:$PATH"

fomenkoandrey’s picture

i have the error in Drupal 8.0.2

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.

netlesh’s picture

8.0.3
drush entity-updates
worked for me

petiar’s picture

Can somebody explain what drush actually does? I have my website on hosting without ssh, I can't use drush, however, I need to fix that problem.

Thanks a lot.

JotaMG’s picture

The same here, no drush... I'm lost!
Anyone can help?

cilefen’s picture

JotaMG’s picture

Ok, the error is:

Entity/field definitions 	
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Content
    Delete the URL alias field.
Taxonomy term
    Delete the URL alias field.

Can someone please explain exactly what this means??
I'm new to Drupal and this type of problems, if not properly explained, can be a blocker to my projects.

cilefen’s picture

#21 is in response to #19, "Can somebody explain what drush actually does?".

It executes: \Drupal::entityDefinitionUpdateManager()->applyUpdates(); and catches a possible exception for logging.

petiar’s picture

Thanks a lot, cilefen, I have added this piece of code

try {
    \Drupal::entityDefinitionUpdateManager()->applyUpdates();
  }
  catch (EntityStorageException $e) {
    print_r($e);
  }

before $response->send(); in my index.php file, reload the webpage and the problem is gone. Of course, then I removed that block from the index.php.

geraldito’s picture

Thanks petiar, #24 worked for me.

TipiT’s picture

#11 works for me too. Thanks!

Strada’s picture

#11 Thanks, it works.

The Drush solution:
http://drushcommands.com/drush-8x/core/entity-updates/

#24 Petiar, your solution works too.

adrian1231’s picture

#24 worked for me as well. For some reason drush (8.0.1) is giving me a bootstrap error when I try to run 'entity-updates'. (drupal 8.0.3)

texis’s picture

#24 Petiar, your solution works too. Thanks

wightowl’s picture

For me this error occurred after adding Pathauto and Token, and updating 8.0.2 to 8.0.3 while following the Drupal 8 Beginner video course on Youtube.

Drush is integrated into the Acquia Dev Desktop 2 program, and available by clicking a button to the right of the 'Local Code' link in the Acquia Dev Desktop 2 window, which you launch to get access to your local site.

Once I found it and got to the command line:
drush entity-updates [Enter]
etc. worked for me. Thanks #11.

Stephen Ollman’s picture

#11 worked for me also.

agoradesign’s picture

@wightowl: this is a known issue in Pathauto, but absolutely harmless, see #2661178-4: Error: Mismatched entity and/or field definitions

baltusf’s picture

Hi Petiar,

Which index.php did you modified for a short time?

Thanks,
Fred

sense-design’s picture

The ROOT index.php of Drupal

Antikpred’s picture

DR core 8.0.3
PHP 7.0.3
drush entity-updates
It's worked for me!

Eric Tiggemann’s picture

#24 Petiar, Thanks a lot. Your solution worked very well for me, too.

chgasparoto’s picture

#24 worked for me in 8.0.5. Thanks man!

topsitemakers’s picture

#11 worked for me as well - just run drush entity-updates should fix it.

hamrant’s picture

Thanks, Wilfred Waltman, #11 worked for me.
Drupal 8.0.5
PHP 5.6.16

bludy1’s picture

I was getting the same error in my status report after installing a few basic contrib modules:

"Entity/field definitions Mismatch detected
Mismatched entity and/or field definitions"

After reading through this thread, I decided to try running update.php, but that didn't get rid of the error. So I decided to try removing modules one by one to see which was causing it. I removed the Pathauto module first and the error was gone.

If anyone knows what I can do to be able to use Pathauto, I'd be extremely grateful. Thanks!

agoradesign’s picture

@ludwebdes: see my comment #32 and the referenced issue. You can safely use Pathauto. The only problem is, that Pathauto uses computed fields, that are currently incorrectly marked as field definition mismatch. There's an open core issue about that already #2673628: Ignore field definition removals/additions from fields with custom storage

vibrasphere’s picture

FileSize
15.56 KB

apermuy’s picture

#11 works fine for me. Thanks a lot!

gplayer01’s picture

@enginpost Drupal Core: 8.06 I had the same issue and ran the following in terminal: drush entity-updates

targoo’s picture

Thanks petiar, #24 worked for me.

jfha73’s picture

drush entity-updates
Worked for me too, thanks.

webmens’s picture

#24 worked for me!

drush entity-updates didn't work for me. Maybe this has something to do with my bootstrap 3 theme.

PHP:  syntax error, unexpected END_OF_LINE, expecting '=' in /usr/local/lib/php.ini on line 2
Fatal error: Class 'Drupal\Core\Session\AccountInterface' not found in /.../core/includes/bootstrap.inc on line 58
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Class 'Drupal\Core\Session\AccountInterface' not found in /.../core/includes/bootstrap.inc, line 58

UPDATE: php.ini error solved by removing space before text. Bootstrap issue is probably because I use an old version of drush. You should probably update drush before trying to use #11

jprstoney’s picture

#24 worked for me. Many thanks.

criscom’s picture

drush entity-updatesworked for me.

sashkernel’s picture

#24 worked for me.

johnno123456’s picture

Thank you Petiar. This worked for me.

This is one of the scary things about Drupal for implementers as distinct from developers.

I have absolutely no understanding of the processes that took place that fixed this issue.

cilefen’s picture

@johnno123456 The source code for EntityDefinitionUpdateManager should shed some light on that for anyone who wants to know.

Note, the fact that this happens at all is an open issue.

digitaldonkey’s picture

#11 helped me on my plain d8

TheDucksLover’s picture

#24 worked for me too ;)

Londova’s picture

In my case there were errors :

#11 : Command entity-updates needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.
The drush command 'entity-updates' could not be executed. Drush was not able to start (bootstrap) the Drupal database.

#24 : The website encountered an unexpected error. Please try again later.
Log: Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: The SQL storage cannot change the schema for an existing field (price in commerce_product_variation entity) with data. in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->updateSharedTableSchema() (line 1376 of /.../core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).

cilefen’s picture

@British-Link

Re #11: That drush error and its solution(s) are well documented elsewhere. It's nothing to do with this specific issue. Without a doubt you cannot execute most drush commands at the moment.

Re #24 That means what it says as far as I know. I'm not sure what comfort that is.

rosso69’s picture

#11 helped for me.

Using drush 8.0.3

numerabilis’s picture

drush entity-updates worked for me! Thanks!
Deu certo! Obrigado!

atul_shin’s picture

If drush not available #24 is best solution for entity fixes, great help.

thanks

osman’s picture

If you have Devel module installed, you can also use the "Execute PHP Code" page at http;//example.com/devel/php


try {
  \Drupal::entityDefinitionUpdateManager()->applyUpdates();
}
catch (EntityStorageException $e) {
  print_r($e);
}

Londova’s picture

In my case, worked a modified command (may be a different version of DRUSH)
drush entup

osman’s picture

@British-Link entup is in fact an alias of the original command entity-updates

Try running drush help entity-updates on command line. It should output something like this:

$ drush help entity-updates
Apply pending entity schema updates.

Aliases: entup
Niyas’s picture

illutek’s picture

Thanks petiar, #24 worked for me just fine.

fomenkoandrey’s picture

Niyas:
did (2), as described in the article, the error disappeared!
Thank you!!!

bas.bakker’s picture

Had the exact same message as #8.

Drupal 8.1.7
drush entity-updates works great

andypost’s picture

Version: 8.0.1 » 8.2.x-dev

This should be fixed in upcoming version

andypost’s picture

Basically this issue affects file_entity module and contact storage - that solved by hack #2629540: Mismatched entity and/or field definitions after installing module

jason.blanda’s picture

Also confirming #24 worked for me.

Christophe Bourgois’s picture

drush entity-updates worked for me as well.

nateB’s picture

Thomas Kaisuka’s picture

drush entity-update worked for me too. Using 8.13

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

zapo’s picture

Drupal 8.1.8, #11 worked for me. Thanks Wilfred Waltman!

tlito’s picture

can you offer solution for virtual hosting where I have not ssh and drush? - I save on hosting plan.

osman’s picture

@tlito see comment #60

majidabed’s picture

#24 works for me too
Thanks

Londova’s picture

After latest Drupal Commerce updates, I have the following message:
---
Mismatched entity and/or field definitions.
Line item. The Data field needs to be uninstalled.
---

After running the command "drush entup", I got the following ERROR:
---
Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException:
Unable to delete a field (data in commerce_line_item entity) with data that cannot be purged. in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->onFieldStorageDefinitionDelete() (line 410 of /home/weblinux/public_html/drupal-8/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).
---
Is there any solution to this problem?

agoradesign’s picture

@British-Link: as Commerce is still in dev, there won't be any update scripts before beta1. Therefore using it implies that you have to carefully watch the changes before running updates. If e.g. entity definitions change, you have to run drush entup, you may need to update configurations manually,..

Yesterday, one of the commits removed the "data" field from line items, as it was considered as unnecessary: https://www.drupal.org/node/2788769

It seems, that you are relying on that. That's not a big problem. You have to implement https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api... in a custom module and re-add the field again.

Londova’s picture

Thank you @agoradesign.
Actually I succeed to update the entities (issue #78) after I delete all orders, including those in carts.

ashokshrestha’s picture

I have pathauto module enabled. When i disabled this module the error removed. But when i enabled pathauto again the error occured again. Is this issue with pathauto module??

Stephen Ollman’s picture

#11 works also for 8.2.0-rc1

Joram’s picture

#24 worked for me for Drupal version 8.1.9.

dani3lr0se’s picture

#11 - Running `drush entup` worked for me as well. I'm also on 8.1.9. Thanks.

There is also this reference to a DrupalEasy blog post that helps too.

thomas.frobieter’s picture

#60 worked great for me. Thanks alot!

Jorgas’s picture

#24 worked fo me. I had this issue after installing pathauto module.
Drupal v. 8.2.0-beta3
Pathauto v. 8.x-1.0-beta1

Berdir’s picture

Status: Active » Closed (works as designed)

There is no bug here as far as all those contrib reports go.

That's the expected behavior if there are differences, some projects don't support updates for dev/pre-beta, the pathauto use case will be fixed in 8.2.

Garryck’s picture

#24 worked for me, when I ran into this error with 8.1.10. Thanks, petiar!

ckoharj’s picture

Using Drupal 8.2.1
Drush version less than 8 so that won't work for me.
#24 did not work for me. Just gave a blank page.
If you can locate the content type that uses that field, (the machine name is on the manage field page, click the edit button for the fields giving you errors, select the field settings tab and save it.
That cleared the errors for me.

Yzmir Ramirez’s picture

PHP 5.5.9
Drupal core 8.1.10 upgrade to 8.2.1

Error message: The node.field_######## field needs to be updated.

drush entity-updates

#11 above Fixed the issue.

labiloute@neuf.fr’s picture

#24 worked for me (8.2.3) ! Cheers :)

sjpagan’s picture

My problem caused from module -> publication_date, this module have't a uninstall function , i try to remove data in db and my operation caused error but

#24 worked for me (8.2.3)
Thank you so much

bogdog400’s picture

I had to run it twice. But #24 did the job. Thanks!

jwineichen’s picture

#60 super helpful easy solution

fshequin’s picture

#24 worked for me too....my DRUSH was manually installed and is not setup correctly. So Drush was not an option for me.

milopca’s picture

#60 works nice for me

rmedard’s picture

#11 Works. Thanks

Adrian83’s picture

I've had a number of recent sites where drush entup was failing to clear the error. Here is how I fixed it in one instance:

#12 here fixed one of my errors. After that I could run drush entup to fix the rest of them. After updating webform the 3rd party libraries were out of date, so I needed to run drush webform-libraries-download. Looking good now.

bigsony’s picture

drush entity-updates worked for me! Thanks!

ppiano’s picture

#24 worked for me (8.3.1)
Thanks!

hilrap’s picture

Thank you!

#60 resolved "The Language Flag mapping entity type needs to be installed."

drupalfan2’s picture

I had this problem after updating from Drupal 8.3.2 to 8.3.3, but my fields contained already data.

The SQL storage cannot change the schema for an existing field

Is there no simple way to update field storage and solve this mismatched entity error when there is already data in the fields?

maxilein’s picture

drush entity-updates did work for me..

rvanderh1’s picture

#60 also worked for me. Thank you!

FlutterStack’s picture

FileSize
102.31 KB

I had similar error when (refer status report Mantance.png image) When I updated my drupal from 8.3.3 to 8.3.7.

drush updatedb --entity-updates fixed for me.

zenimagine’s picture

Is there an equivalent command with the console ?

frankcarvajalr’s picture

Wilfred Waltman esta en lo correcto la forma de solucionar el inconveniente es con (drush entity-updates)

handkerchief’s picture

I updated from 8.3.7 to 8.4.0-rc2

Now i have this message:

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
File

The File type field needs to be updated.

So I tested all the options above, one for example:

drush entity-updates

result message after drush command:

Cache rebuild complete.                                                                                                                                                                                                                                   [ok]
Finished performing updates.

but the error message remains, no matter how many times I run an update. any ideas?

lakenney’s picture

@Nayis #63
Thank you! That worked for me. Drush commands didn't work.

handkerchief’s picture

FileSize
7.02 KB

for me this does not work. Also not with the devel-php-variant. As with the drush commands, it seems that it worked, but did not, the message does not disappear.

field_definitions.png

zenimagine’s picture

what is the equivalent of this console command ?

lehoa85’s picture

I had same issue #110 when upgrade to drupal 8.4.0 without fix by running drush entity-updates

How to fix it?

steveoriol’s picture

Same as #110 ( after upgrade to drupal 8.4.0 and upgrade drush8 to drush9 to try "drush entup", without success)...

steveoriol’s picture

FileSize
32.01 KB

drush entup

ronaldmulero’s picture

drush entity-updates
Worked for me.
Drupal core 8.4.0
Drush 8.1.14

handkerchief’s picture

still no success with:
Drupal 8.4.0
Drush 8.1.12

steveoriol’s picture

@ronaldmulero and @handkerchief,
How could you use Drush 8.x with Drupal 8.4
Normally you should use Drush 9.x for Drupal 8.3+, Drush 8.x is for Drupal 8.3-
See: http://docs.drush.org/en/master/install/#drupal-compatibility

handkerchief’s picture

@steveoriol: I followed this description: https://www.drupal.org/project/drupal/releases/8.4.0

But I will try it with Drush 9.

handkerchief’s picture

Still no success with:
Drupal 8.4.0
Drush 9.0.0-beta6

ollioi’s picture

I got the same problem. After update to Drupal 8.4.0 the "Entity/field definitions Mismatch detected" message shows up.
Using drush (Version 8.1.13) entity-update runs without error message, but the message still appears. I've run the command several times with no success.

wolfthesad’s picture

Same problem here after upgrade to dupal 8.4.0. Drush 9 did not help either. After further investigation, I found out that that the contributed File entity module, which I had installed, was now mostly in drupal core, hu. A conflict between between the old contrib and the new core module? After uninstalling this module and running the php code from #24 everything got back to normal and the issue was no longer mentioned in Status report.

bander2’s picture

Same problem after updating to Drupal 8.4.0. Tried drush 8.1.13 and 9.0-dev-g2852ef7. No luck.

Is there a manual way to fix this? How can I tell which field has the issue? I don't have a field called "File type".

gmaxwelled’s picture

Same problem, and I also have File entity module installed. I don't think uninstalling this is an option for me though.

handkerchief’s picture

Status: Closed (works as designed) » Active
cilefen’s picture

Status: Active » Closed (works as designed)

@handkerchief Please open a new issue specifically for the file mismatch rather than reopen this epic. Thank you!

cilefen’s picture

Cheviot’s picture

I use
drupal 8.4.0
Composer version 1.5.2
Drush 9.0-dev-g2f52b20
PHP 7.0.18

I cannot resolve a Drush entup, see below. Drush recommends uninstalling a publishing field. There is no such thing as uninstalling the publishing field for "custom block", how can this be resolved for "custom block" which is a core item?

see below:

The following updates are pending:
block_content entity type :
The Publishing status field needs to be uninstalled.

Do you wish to run all pending updates? (yes/no) [yes]:
> yes

[error] Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: Unable to delete a field (status in block_content entity) with data that cannot be purged. in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->onFieldStorageDefinitionDelete() (line 428 of /library/webserver/documents/named/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).

In the status report I see

Entity/field definitions
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.

Custom block

The Publishing status field needs to be uninstalled.

cilefen’s picture

@Cheviot Please open a new issue for that.

liquidcms’s picture

During module development i have gotten my test site into a state with numerous "Mismatched entity and/or field definitions". But these are due to various forms of corrupted fields. As with Drupal 7, Drupal 8 still has many poorly written routines which, upon any error, simply crash. Running drush entity-update or the script in #11 results in same error:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal8.node__field_category' doesn't exist: UPDATE {node__field_category} SET deleted=:db_update_placeholder_0; Array ( [:db_update_placeholder_0] => 1 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->onFieldStorageDefinitionDelete() (line 1479 of E:\www\drupal8\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php).

which simply means field table was missing and the D8 db api can't handle this. As a result, none of the "API approaches" listed above are likely to work.

Most likely only method to truly clean out corrupted fields is to manually clean up the DB (or a better written script which removes individual field pieces in the DB. I am in the process of writing a module which will "force" delete fields. I'll post here when i have it working.

liquidcms’s picture

To continue with my plan from #129 i think pieces of a field are scattered through the db in:

- entire data (no longer called this in D8) and revision tables
- entire records in key_value, config and cachetags tables
- buried in serialized records in config and key_value tables

and the killer: binary records in the key_value table

I have no idea how to remove the reference to my corrupt field out of the binary data stored in key_value table so I would have to go out on a limb and suggest it is not possible to completely clean up corrupt fields in D8 (so easy in D7).

not sure why phpmyadmin and navicat both could not display key_value record but it is simply a very large serialized value. Once that last part was removed from the array; the field no longer shows on status report.

Abdelhamid’s picture

thanks to @Wilfred_Waltman I had the same error and "drush entity-updates" has fixed it for me :D

dark_kz’s picture

drush entity-updates didn't work for me.
My field type is field_collection

➜  www git:(master) ✗ d8 entity:updates
The following updates are pending:

node entity type :
The node.field_authority_phone field needs to be updated..

 Do you wish to run all pending updates? (yes/no) [yes]:
 > yes

 [error]  Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_authority_phone_value' in 'where clause': SELECT 1 AS expression
FROM
{node_revision__field_authority_phone} t
WHERE (field_authority_phone_value IS NOT NULL) OR (field_authority_phone_revision_id IS NOT NULL)
LIMIT 1 OFFSET 0; Array
(
)
 in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1513 of /Users/dark/Sites/drupal8/www/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
 [error]  Failed: Drupal\Core\Entity\EntityStorageException: !message in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1513 of /Users/dark/Sites/drupal8/www/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
 [error]  Failed: Drupal\Core\Entity\EntityStorageException: !message in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1513 of /Users/dark/Sites/drupal8/www/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
trentwyman’s picture

This contrib module was recently released that can run entity-update through the UI.
https://www.drupal.org/project/entity_update

Mingsong’s picture

Easy solution #60 works for me.

Thanks a lots.

Since this is a very common issue, I am wondering if it is possible to add the entity updating feature into the update.php?

In this way, a site builder just simply run the update.php without installing any contribute modules or coding need.

It is quite important for production environment in which we don't want to install Devel module and Drush or hack the core index.php file.

paperscenery’s picture

Another thumbs up for solution #60. Sağol @osman

rkchallengers’s picture

#24 Worked for me. Thank you!

imanoop’s picture

Finally this is working for me #24 .
Added the code to the end of my Index.php and clean site cache and error is gone then remove that code from there.

Stephen Ollman’s picture

#24 totally killed my site. Thank god I had a backup.

Anonymous’s picture

#24 worked for me. Using Drupal core 8.5.5 on Pantheon. Thank you petiar!

ExTexan’s picture

I tried the "drush entity-updates" method to fix this issue, but it didn't work for me.

In my case, the Status Report says: "The node.comment field needs to be uninstalled." ...but when I run "drush entity-updates", it says:

"Base table or view not found: 1146 Table 'node__comment' doesn't exist"

It is trying to update the deleted column in that table with "1".

Any suggestions on how to fix this? It seems my site is stuck between an update that it "thinks" needs to be run, and a non-existent table (because the comment module has been uninstalled).

maxilein’s picture

reinstall the comment module and try again...

ExTexan’s picture

@maxilein, Thanks for the suggestion. I had tried that already. I really thought that would fix it, but, alas, no.

maxilein’s picture

a similar situation with some other module has worked for me. Butit was not the comment module..

David Radcliffe’s picture

(deleted)

Rick Hood’s picture

Error seen on /admin/reports/status

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
User
The UUID field needs to be installed.
The Language code field needs to be installed.
The Preferred language code field needs to be installed.
The Preferred admin language code field needs to be installed.
The Name field needs to be installed.
The Password field needs to be installed.
The Email field needs to be installed.
The Timezone field needs to be installed.
The User status field needs to be installed.
The Created field needs to be installed.
The Changed field needs to be installed.
The Last access field needs to be installed.
The Last login field needs to be installed.
The Initial email field needs to be installed.
The Roles field needs to be installed.
The Default translation field needs to be installed.
The user.field_domain_access field needs to be installed.
The user.field_domain_admin field needs to be installed.
The user.field_domain_all_affiliates field needs to be installed.
The user.user_picture field needs to be installed.

Running drush entup returns this error:

Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. Cannot add unique key user_field__uuid__value to table users: unique key [error]
already exists. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1531 of
/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Doing this seems to get rid of the drush entup error:

ALTER TABLE users DROP INDEX user_field__uuid__value;

I guess I need to do that on the live database. Don't ike it but will give it a shot.

Boldizart’s picture

#24 worked for me. Thanks. :)

GaëlG’s picture

I had the "table doesn't exist" error for a field I had deleted (field_date), each time I tried to execute drush entup (same as #129 and #140).
This is how I fixed it:

drush sqlq "CREATE TABLE node__field_date ( deleted INT )"
drush sqlq "CREATE TABLE node_revision__field_date ( deleted INT )"
drush entup
drush sqlq "DROP TABLE node__field_date"
drush sqlq "DROP TABLE node_revision__field_date"
miscdr’s picture

Solution #133 worked for me.
Thank you very much.

MartinMa’s picture

Just had this problem more than a half year ago, and #24 solved it (as code on index.php).

But now I have on one site the problem again and #24 / #60 dont still work, on php console of devel module I get following error message:

Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: The SQL storage cannot change the schema for an existing field (field_sprache in node entity) with data. in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->updateDedicatedTableSchema() (Line 1481 in /core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).

Unfortunately I couldnt install drush on my server ...

lias’s picture

#24 worked for me also - affected 8.6.1 upgrade with token 8x-1.5

gngn’s picture

I solved the problem with the contrib module entity_update (mentioned in #133 by trentwyman) using the drush commands given at "Advanced use for complex updates" (i.e. with existing content).

Basically it:

  • dumps the data to file,
  • deletes the data,
  • updates the entity structure,
  • and re-imports the data from file

Thanks!

tjtj’s picture

drush entity-updates goes in a loop for me:

-bash-4.2$ ./drush entity-updates
The following updates are pending:

node entity type :
The node.feeds_item field needs to be uninstalled

In Statement.php line 59:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'orcmaorg_d8.node__feeds_item' doesn
  't exist


batch:process [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--druplicon] [--xh-link XH-LINK] [--notify [NOTIFY]] [--] <command> <batch_id>


In Connection.php line 686:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'orcmaorg_d8.node__feeds_item' doesn
  't exist: UPDATE {node__feeds_item} SET deleted=:db_update_placeholder_0; Array
  (
      [:db_update_placeholder_0] => 1
  )


In Statement.php line 59: ..... and so on

How does one fix this?

perkedel’s picture

Had this problem from 8.x-5.0-rc29 to 8.x-5.0-rc30.

No drush here, so I couldn't use that solution.

#11 Fixed it.
https://www.drupal.org/project/drupal/issues/2601762#comment-10743216

Anne-Pierre’s picture

Thanks petiar, #24 worked for me.

karolus’s picture

Had the same issue updating from 8.x-5.0-rc30 to 8.x-5.0.

@perkedel's suggestion (#153) fixed it for me.

Now, one question—why isn't this included in the update hook?

Lalith Manage’s picture

Version: 8.3.x-dev » 8.6.4

#24 worked for me after upgrading from Drupal Core 8.6.3 to 8.6.4.
petiar, thanks a bunch!

tjtj’s picture

#24 kills my site.
#11 goes into a loop:

In Statement.php line 59:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'orcmaorg_d8.node__feeds_item' doesn't exist


batch:process [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--druplicon] [--xh-link XH-LINK] [--notify [NOTIFY]] [--] <command> <batch_id>


In Connection.php line 686:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'orcmaorg_d8.node__feeds_item' doesn't exist: UPDATE {node__feeds_item} SET de
  leted=:db_update_placeholder_0; Array
  (
      [:db_update_placeholder_0] => 1
  )


In Statement.php line 59:
frederico’s picture

#24 Petiar, your solution works. Thank you!!! For reference, I have Drupal 8.6.4 and Webform 8.x-5.0.

william.jieh’s picture

#24 works for me! Thanks!

themic8’s picture

#24 didn't work for me. Error: Drupal\Core\Entity\EntityStorageException: The SQL storage cannot change the schema for an existing entity type
Core: 8.6.16

gngn’s picture

@themic8:

Error: Drupal\Core\Entity\EntityStorageException: The SQL storage cannot change the schema for an existing entity type

That's just the problem - drupal cannot change the schema if you have existing data.
Did you try the contrib module entity_update (mentioned in #133 and #151)?
That worked for me.

sharif.elshobkshy’s picture

Do not apply #24. It will run that snippet on every load page. It should only be run once.
Also, index.php or any other core file should not be manually changed.

ntaylor1994’s picture

#161 didnt work for me. This happened going from 8.6.15 to 8.7.0 and 8.7.1. Some tables in my DB are marked "old" and some of my pages return a 404, even though they were there before the upgrade. Is this a known bug in 8.7?

pritam.tiwari’s picture

Neither #11 nor #24 worked in my case.
I have done Drupal core update from version 8.5.7 to 8.7.1.
With drush entup command completes successful but the error in the admin back-end still persist.

cilefen’s picture

jimafisk’s picture

Same problem going from drupal/core (8.6.16 => 8.7.1).

The status report page ("/admin/reports/status") shows:

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.

Running a drush entup shows:

The following updates are pending:

comment entity type : 
The Entity type field needs to be updated.
The Comment field name field needs to be updated.

After typing "yes" drush says it completes successfully, but the updates are still pending.

After the 8.7 upgrade I can continue to access the "/user/login" URL and my logged in session continues to work, but anonymous traffic gets the following error:

Drupal\Component\Plugin\Exception\ContextException: The 'entity:user' context is required and not present. in Drupal\Core\Plugin\Context\Context->getContextValue() (line 73 of /app/web/core/lib/Drupal/Core/Plugin/Context/Context.php).

Update: I was able to successfully run the entity updates via drush by adding the Devel Entity Updates module. The "entity:user context is required and not present" may be a separate issue, so moving that conversation here: https://www.drupal.org/project/drupal/issues/3057399

jjwfcd’s picture

when I run the drush entity-updates, it alert

The SQL storage cannot change the schema for an existing field (field_image in node entity) with data.

8.6.16

PepeMty’s picture

I confirm that, as per the update of #166, devel_entity_updates worked for me.

Warm regards from sunny México.
José

vrwired’s picture

I can also confirm #166 is current solution.

Thanks for noting that discovery @jimafisk! Normally I skip to the end of issue queue to find latest solution and should have done so again in this case sooner than later.

It was just baffling that drush entup notified success even though had not yet installed the Devel Entity Updates module.

What a long standing issue this is, taking new turns as D8 evolves!

joonapenttila’s picture

I can confirm #166 works !

suparnaa.dey’s picture

#166 works for me as well. Thanks @jimafisk

handkerchief’s picture

I tried #166 and I think it worked. Anyway, the update messages are gone.

codeyourdream’s picture

#166 worked, thank you

andres.torres’s picture

+1 for #166. Thanks for the tip!

mano2003’s picture

+1 for #166. Works for me, thanks!

glynster’s picture

+1 for #166. Once installed I could then run:

drush entity-updates

Problem resolved.

tjtj’s picture

ignore this

Alen Simonyan’s picture

If you have error like this - "The Adjustments field needs to be installed." you need to run
drush updb

siddiq’s picture

Automatic entity update is not supported after 8.7. So I can't run drush entity-updates now. But still getting this error for multiple modules. Anyone came across this issue. My updated Drupal version is 8.8.5

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
File

  • The URL alias field needs to be installed.
  • The File type field needs to be updated.

Flagging

  • The Flag field needs to be updated.

Taxonomy term

  • The Moderation state field needs to be installed.
mario.elias’s picture

Can anyone help with Mismatched entity and/or field definitions error"

Errors found
ENTITY/FIELD DEFINITIONS
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Paragraph
The paragraph.field_reusable_paragraph field needs to be updated.

I am using Drupal core 8.8.5 and Drush version : 9.7.2. I have the fallowing modules:

Paragraphs                        Paragraphs Demo (paragraphs_demo)                                                    Disabled   8.x-1.11
Paragraphs                        Paragraphs Library (paragraphs_library)                                              Enabled    8.x-1.11
Paragraphs                        Paragraphs Type Permissions (paragraphs_type_permissions)                            Enabled    8.x-1.11
Paragraphs                        Paragraphs (paragraphs)                                                              Enabled    8.x-1.11
Slick                                 Slick Paragraphs (slick_paragraphs)                                                  Disabled   8.x-2.0

I get error running sql query updates;
drush sql:query "UPDATE paragraph.field_reusable_paragraph SET status = 0 WHERE status is NULL"

In SqlCommands.php line 199:
                 
  Query failed. 

Thank you

Berdir’s picture

Create a new support issue in paragraphs or try #drupal-support on Slack or maybe Drupal answers, commenting on closed issues won't really get you any responses as most people don't even see that.

wavesailor’s picture

Version: 8.6.4 » 10.0.x-dev

Solution #133 worked for me.

PiRoth’s picture

I had an error with FEEDS (node.feeds_item needs to be updated).
Solution #133 (using the Entity Update module) resoled the problem.

zakariabdc’s picture

#133 worked for me

I had this error at /admin/reports/status :

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Content

  • The Title field needs to be updated.

This module: https://www.drupal.org/project/entity_update solved the error.