Problem/Motivation
After update from 8.1.4 to 2.0.0 via composer I got that error in the status report. I made an database update and cleared all caches, but the error still exists. Any suggestions?
Steps to reproduce
Update the module from any 8.x-1.x
This does not happen for fresh installations
Proposed resolution
Add an update hook to install the schema - ONLY IF IT DOES NOT YET EXIST! (as the update hook will also affect fresh installations!)
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork riddler-3313384
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
ab_connor commentedComment #3
VValdo commentedSame issue. How to fix it?
Comment #4
anybodyI can sadly confirm this. This does NOT happen for fresh installations of riddler, but only for updated, existing installations, as in this case Drupal doesn't maintain the schema change and it has to be done in an update hook.
Don't be afraid, everything should still work as expected, the next update will bring the schema fix.
This can be reproduced by installing riddler 8.x-1.x and then updating to 2.x.
Proposed solution:
Add an update hook to install the schema IF IT DOES NOT YET EXIST! (as the update hook will also affect fresh installations!)
See
https://www.drupal.org/docs/drupal-apis/update-api/updating-configuratio...
Comment #5
anybodyFor details see:
https://www.drupal.org/node/2554097
I finally found a good and very similar example in this Geocoder issue: #3172255: Install new config entity type via update hook.
https://git.drupalcode.org/project/geocoder/-/commit/f745c0b1589b3c13a87...
We should DEFINITELY add documentation for this. Best would be if Drupal could provide a helper for this typical case...
Comment #6
anybodyI finally created a core issue / support request for this: #3313665: How to install a new entity type from class annotations in an update hook
Comment #7
anybodyLet's wait if we get feedback for a better DX solution. Until that I'll mark the 8.x-1.x version supported and recommended again to not confuse further people, until this is fixed.
Comment #8
anybodyComment #9
anybodyComment #10
anybodyComment #12
anybodyJust had an idea how this might be solved cleanly. Please test and review (but please not in production environments!)
And please test for fresh 2.x installations and updated installations from 1.x
Comment #13
grevil commentedWorks great! Tested it with a fresh Drupal installation, upgrading from 1.x to 2.x AND installing 2.x straight with another fresh Drupal installation. Also, I ran config inspector and no errors occurred!
I think I oversaw this issue, because somehow the entity was still registered for me, when upgrading because I did not use a fresh Drupal installation, to test the update hook originally.
Comment #15
grevil commentedI set the default branch back to 2.x! Thanks for the heads-up @ab_connor!
Comment #16
grevil commented