Problem/Motivation
After updating to the last 8.x-1.x-dev version, I'm getting the following message in Status report:
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Contact
The First Name field needs to be updated.
The Middle Name field needs to be updated.
The Last Name field needs to be updated.
I have tried to use the Devel Entity Updates module to fix it, but then I'm getting:
In SqlContentEntityStorageSchema.php line 1887:
The SQL storage cannot change the schema for an existing field (first_name in redhen_contact entity) with data.
Any hint about a better way to fix it will be welcome.
Issue fork redhen-3163820
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
gcbComment #3
seanrI ran into this today. Any advice would be greatly appreciated. This occurred as part of a D9 upgrade, but I'm not entirely sure where the update flopped (I may have missed it in updating everything to latest D8) - my suspicion is that redhen.install is missing something.
Comment #4
chertzogHaving just updated 5 redhen installs to D9 over the past month, this is still an issue. That being said, it hasnt stopped me or presented any problems just so far, so it has been a pretty low priority item.
I'm hoping to find some time in the next couple weeks to see where thee breakdown is and work up a patch.
Comment #5
seanrIt seems to me there was a missed/deleted update hook in one of the various version upgrades to this module?
Comment #6
seanrComment #7
seanr[message deleted]
Ugh, that didn't work either (I forgot I'd deleted the contacts in my local test environment). Stuck at square one. How the hell do I get a working update to fix these f***ing fields?!?
Comment #8
seanrThis finally worked:
Comment #9
gcbThanks, this is really handy!
The reason we didn't have a hook update was two factors: one was it seemed hard, as you have discovered, and the other is that the change was made back in alpha and... ya know, alpha isn't stable anyway. But this is really helpful.
I'm mildly concerned about timeouts on large databases, though, and I'm also concerned about running this on sites that have already made the change in some other way. For this reason, I think it would be better as a drush command.
Comment #10
chertzogInitial testing of #8 does in fact resolve the errors, but now none of my contacts have names. My initial guess is that its due to the number of records. i've got ~20k contacts.
Comment #12
gcbOk, drush command added. It'll be in the next release.
Comment #14
seanr@gcb - I think this needs to be reopened. It turns out it's not updating the fields in the redhen_contacts_revision table.
Comment #15
seanrAdding this at the end solved that:
Comment #16
chertzog+1 for re-opening this and adding #15 to the end of the update hook
Comment #17
gcbComment #19
Harlor CreditAttribution: Harlor at erdfisch commentedI think the main reason the message appeared in the status report is that the maxlength was changed in https://git.drupalcode.org/project/redhen/-/commit/2ed52ef4c775e0a18c111... without updating existing DBs.
Usually the definition_update_manager makes all the DB changes and no explicit DB commands are needed. AFAIK The typical place for these updates is a post_update hook - So I moved the script from the drush cmd too the hook and removed the manual DB actions.
Comment #20
tobiasb@Harlor
Thx. proper solution for such updates.
Comment #23
gcb