After upgrading core to D.8.7.0, trying to upgrade from 8 1.2 to 8.19
I can't run the update db
The following updates are pending:
consumers module :
8103 - Make consumers translatable.
8104 - Add field 'is_default'.
8105 - Create a default consumer.
8106 - Update entity definition to add the "owner" key and adapt the field.
It is not possible to change the entity type schema outside of a batch context. Use EntityDefinitionUpdateManagerInterface::updateFieldableEntityType() instead. [error]
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 3052959-25.patch | 196.49 KB | phenaproxima |
| #24 | 3052959-24.patch | 196.52 KB | phenaproxima |
| #23 | 3052959-23.patch | 196.19 KB | phenaproxima |
| #12 | 3052959-12.patch | 6.58 KB | phenaproxima |
| #11 | interdiff-3052959-7-11.txt | 4.16 KB | phenaproxima |
Comments
Comment #2
szeidler commentedIt's related to the change in Drupal 8.7: https://www.drupal.org/node/3034742
I'm wondering how that should be dealt with in general. Meaning now, when I'm upgrading to Drupal 8.7 it's kind of easy to go back to 8.6.x, update the affected module (here "consumers"), run the update hooks and then perform the core update to 8.7 afterwards.
But what happens in 6 months, when the sites have been on 8.7 for a while and then a contrib module (which was not updated for some time for some reason) is going to be updated, which includes entity type schema updates. It's probably not the best practice to change update hooks for the past, but I guess it would work. The problem I see is, that the maintainers usually update their modules much more frequent, so they will not encounter an issue like this. I'm afraid this could be troublesome for a couple of contrib modules.
I guess it could be argued, that contrib should be kept up-to-date and it might be recommended to update contrib before doing a core upgrade. But those problems will happen.
Comment #3
phenaproximaI'm hitting this as well. I'm bumping this to Major (personally, I think it should be Critical) because it completely breaks the update path to Drupal 8.7.
Comment #4
phenaproximaHere is a quick, sloppy attempt at a patch. Not sure if this will work, but I'll test it.
Comment #5
phenaproximaTrying to eliminate a new error ("Unsupported entity type")...
Comment #6
phenaproximaI went to @Berdir and @amateescu for advice on this, since they understand the entity update system better than just about anybody.
Here's how our conversation in Slack went (some comments removed for brevity):
So this is going to need to be discussed with the maintainer, and might even necessitate a new major version of the module. Not sure...
Comment #7
phenaproximaHow does this look?
Comment #8
phenaproximaThis didn't work, sadly; I got the following error (drush updb):
> [error] Unsupported entity type
> [error] Update failed: consumers_update_8107
:( Any thoughts?
Comment #9
amateescu commentedWe also need to call the parent method here.
We need to set a few additional things on these base field definitions:
and
Comment #10
amateescu commentedAlso, the update function should be a post_update one, and we need to return early if the entity type is already translatable :)
Comment #11
phenaproximaThanks, @amateescu! How does this look?
Comment #12
phenaproximaUgh; I had named the post-update file consumers.post_update.module. My bad!
Comment #13
amateescu commented@phenaproxima, this looks much better. I think there's just one thing missing: in the post-update function we also need to set the new storage class on the entity type object.
Comment #14
amateescu commentedAlso, since we are using the new Entity Update API from 8.7.0, the module needs a dependency on this version of core.
Comment #15
jazzslider commentedHello! I'm curious about the state of the patch in the previous comment —it looks like there are still a few small-ish changes that need to be made, but for site maintainers currently blocked by this problem, is it safe to use the patch as-is to work around the issue?
Comment #16
phenaproxima@jazzslider, I've been using it and it seems okay, more or less. But, if you're up for it, please feel free to make the changes to the patch here, then maybe we can get it committed quickly. :)
Comment #17
smustgrave commentedI applied the patch from #12 but I receive the following. How are you getting it to work?
[error] Exception thrown while performing a schema update. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.label' in 'field list': SELECT base.id AS id, base.uuid AS uuid, base.owner_id AS owne
r_id, base.label AS label, base.description AS description, base.image__target_id AS image__target_id, base.image__alt AS image__alt, base.image__title AS image__title, base.image__width AS image__width, base.i
mage__height AS image__height, base.third_party AS third_party, base.secret AS secret, base.confidential AS confidential, base.redirect AS redirect, base.user_id AS user_id, base.is_default AS is_default
> FROM
> {consumer} base
> WHERE base.id IN (:db_condition_placeholder_0); Array
> (
> [:db_condition_placeholder_0] => 1
> )
>
> [error] Update failed: consumers_post_update_make_consumer_entity_type_translatable
Comment #18
smustgrave commentedAny movement on this?
Comment #19
eojthebraveWhat's the best way for me to replicate this problem in order to test the patch? Do I need to install a version of consumers module before
consumers_update_8103()was introduced? And then move to the latest version and run the updates?Comment #20
szeidler commented1. Install Drupal 8.6.x
2. Install Consumers 8.x-1.2
3. Upgrade Drupal to 8.7.x (Automatic entity updates will stop working from here)
4. Upgrade Consumers to 8.x-1.9 (The update hook 8103 should fail).
When using the patch, step 4 should be successful.
Comment #21
Syntapse commentedsubscribing.
I'm running 8.7.5 so comment #20 wont work in my case.
I've been having very similar problems I am already running 8.7.5 and hitting problems with installation.
https://www.drupal.org/project/consumers/issues/3081101 contains links to admin screen shots basically i cant install database updates due to version incompatability errors.
Are there any plans to make consumers "just work" on 8.7.x and above?
thanks
Comment #22
eojthebraveOkay. I've tested this out, and the patch in #12 works for me in these scenarios:
consumers_update_8103()was added in 8.x-1.0-beta4. Though, I did test and see the failure occur without the patch applied. And the failure resolved after the patch was aplied.According to #14 the patch here still needs to update the .info.yml file to reflect that it's dependent on core >= 8.7.0.
I also took a look at the code and it looks correct to me. That said, I don't know a whole lot about the Entity Update API so I'm not totally comfortable reviewing the code as I just don't know what I might be missing. It would be great to get a sign off from someone like @amateescu (or really anyone who feels comfortable with the update API) on the code changes if possible.
Comment #23
phenaproximaHere's the same patch, including a test of the update path all the way from Consumers 8.x-1.0-beta1 on Drupal 8.4.0. Whew! It will fail the test because there are other bugs in the update path, but at least now we have a path to get them fixed.
Most of this patch is a binary database fixture, so ignore that part.
Comment #24
phenaproximaThis will still fail, but for different reasons.
Comment #25
phenaproximaLet's see if this passes. Worked for me...
Comment #26
phenaproximaRe-titling for accuracy, and escalating this to Critical priority. The update path has straight-up bugs in it, which can break sites or modify data in unexpected ways, and if that's not critical, I don't know what is. This patch at least mitigates the known problems by testing the update path as far back as it goes, and correcting any failures that happen in the course of the update.
Comment #28
eojthebraveThanks @phenaproxima for finishing this up, and especially for adding tests to prove it's working as expected. And thanks @amateescu and @szeidler for help with reviews and testing. You all rock!
I've committed the patch from #25. I'm going to see what if any other open issues this helps fix. And then I'll tag a new release.
Comment #29
eojthebraveComment #30
sam711 commentedDoesn't this patch fix the previous #3032218: Consumers owner_id field schema differs from database column?
Comment #31
eojthebrave@sam711 I believe it does, but I haven't confirmed it yet. If you can confirm that it does indeed fix #3032218: Consumers owner_id field schema differs from database column feel free to mark it as a duplicate of this one.
Comment #32
sam711 commented@eojthebrave It fixes part of the problem and simplifies it.
I've updated #3032218: Consumers owner_id field schema differs from database column to address the remaining part and be consistent with HEAD.
Comment #33
e0ipsoThanks for the contributions everyone!