Problem/Motivation

After updating the module to the latest version(8.x-1.4), these are some database updates available. make_group_revisionable update fails.

Steps to reproduce

1. Update to 8.x-1.4 version
2. Run drush updb

See comments below. The error is related to lightning_workflow or lightning_scheduler as a dependency. A patch for lightning_workflow is linked. A similar patch needs to be created for the standalone version of lightning_scheduler.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

saurabh-2k17 created an issue. See original summary.

saurabh-2k17’s picture

Status: Active » Needs work
philjubb’s picture

Same for me. Core 8.9.18

Error is:
> [notice] Update started: group_post_update_make_group_revisionable
> [error] Exception thrown while performing a schema update. SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.group__scheduled_transition_date' doesn't exist: SELECT t.*
> FROM
> {group__scheduled_transition_date} t
> WHERE (entity_id IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5)) AND (deleted = :db_condition_placeholder_6) AND (langcode IN (:db_condition_placeholder_7, :db_condition_placeholder_8, :db_condition_placeholder_9))
> ORDER BY delta ASC; Array
> (
> [:db_condition_placeholder_0] => 2
> [:db_condition_placeholder_1] => 3
> [:db_condition_placeholder_2] => 4
> [:db_condition_placeholder_3] => 5
> [:db_condition_placeholder_4] => 6
> [:db_condition_placeholder_5] => 8
> [:db_condition_placeholder_6] => 0
> [:db_condition_placeholder_7] => en
> [:db_condition_placeholder_8] => und
> [:db_condition_placeholder_9] => zxx
> )
>
> [error] Update failed: group_post_update_make_group_revisionable
[error] Update aborted by: group_post_update_make_group_revisionable
[error] Finished performing updates.

abaracus’s picture

Same issue over here as well. Any quick work arounds for now? :/

lesleyfernandes’s picture

Facing the same issue here.

lesleyfernandes’s picture

 -------- ------------------------- ------------- --------------------- 
  Module   Update ID                 Type          Description          
 -------- ------------------------- ------------- --------------------- 
  group    make_group_revisionable   post-update   Update groups to be  
                                                   revisionable.        
 -------- ------------------------- ------------- --------------------- 


 // Do you wish to run the specified pending updates?: yes.                                                        

>  [notice] Update started: group_post_update_make_group_revisionable
>  [notice] Groups have been converted to be revisionable.
>  [error]  Exception thrown while performing a schema update. Cannot rename 'tmp_7b6962groups_revision' to 'groups_revision': table 'groups_revision' already exists. 
>  [error]  Update failed: group_post_update_make_group_revisionable 
 [error]  Update aborted by: group_post_update_make_group_revisionable 
 [error]  Finished performing updates. 
caesius’s picture

Getting this as well on Drupal 9.2.7; we had been using the 1.x-dev version previously:

>  [notice] Update started: group_post_update_make_group_revisionable
>  [error]  Exception thrown while performing a schema update. SQLSTATE[42S02]: Base table or view not found: 1146 Table 'web.group__scheduled_transition_date' doesn't exist
kristiaanvandeneynde’s picture

Can you all please specify the exact version you came from and if using dev (which you really shouldn't) which commit? Can you also tell me if you are using any invasive patches such as the one that allows config entities to be grouped?

caesius’s picture

In our case we are unfortunately using several patches on commit 2310cbf

    "drupal/group": {
      "Entities identified by strings as group content": "https://www.drupal.org/files/issues/2021-05-17/group-support_string_entity_ids-2797793-256.patch",
      "Get a token of a node's parent group to create a pathauto pattern": "https://www.drupal.org/files/issues/2018-12-19/group-2774827-41-gnode-tokens.patch",
      "Fix user permissions on creating new content but not associating existing content": "https://www.drupal.org/files/issues/2019-01-04/2842630-20.patch",
      "Set content moderation permissions on the groups level": "https://www.drupal.org/files/issues/2020-06-09/group-content_moderation-2906085-74.patch",
      "https://www.drupal.org/project/group/issues/2815971": "https://www.drupal.org/files/issues/2021-02-19/2815971-28.patch"
    },

Additionally we have a custom patch to lightning_scheduler for Group integration, which... seems to be where the scheduled_transition_date field comes from. In other words we'll probably need to develop a solution to this ourselves. Sorry for the trouble!

rokzabukovec’s picture

Please check if the groups_revision, groups_field_revision, group_revision__field_ tables exists already in the database. In my case the issue was that this db update already ran once and the tables were already in the db. The error message was that those tables already exists.

kristiaanvandeneynde’s picture

Status: Needs work » Closed (works as designed)

Okay given the latest comments, closing this.

caesius’s picture

For the record I just noticed that #3 has the same error with the same table that I had, even though as far as I can tell the patch we use for Group integration with Lightning Scheduler is custom and does not exist elsewhere on the web. So it may be that this issue occurs when updating Group while also having Lightning Scheduler installed and our custom patch had nothing to do with it.

(update: just consulted internally with the devs that actually wrote our custom patch and it appears that all the patch does is integrate scheduling permissions with group permissions, so it seems more likely that this is an OOTB bug with Lightning Scheduler + Groups)

That said, I don't have the expertise to figure out if this is an issue with the Group module or the Lightning Scheduler module. Perhaps the Lightning Scheduler module is providing the scheduled_transition_date field in a way that the Group update hook doesn't account for? Either it's uncommon (Group's fault) or incorrect (LS's fault)

Hopefully we will be able to figure this out internally and come back with an update, but it will take some time.

philjubb’s picture

#8 coming from 1.3 -> 1.4. Not using dev.

#12 we're also using Lighting Workflow (includes Scheduler) but not using any custom integration with Groups. I can't see the LW messing around with Group tables though.

We're not getting errors about existing tables, just missing tables.

kristiaanvandeneynde’s picture

Re #12: Please do come back if you have a definitive answer that points to a bug in Group. or even if it doesn't just to let the others know :)

scottalan’s picture

@lesleyfernandes I'm getting the same error you were/are getting in #6

Were you able to resolve this issue? If so, how?

philjubb’s picture

Status: Closed (works as designed) » Needs work

This was closed but based on a comment from someone other than the OP. The original issue was that the tables were missing, not that they were already there. So the thread was hijacked with a different issue and should have spawned a separate issue.

kristiaanvandeneynde’s picture

Status: Needs work » Closed (cannot reproduce)

Right, I'm going to close this one because:

  • It has been sidetracked too much
  • It does not have clear steps to reproduce

The IS states that this will happen with the following steps:

  1. Update to 8.x-1.4 version
  2. Run drush updb

Yet the amount of people reporting this is minimal, so it's obviously not happening on all installations of Group. Please provide proper steps to reproduce in a new issue and then we can discuss this without being sidetracked. Most importantly see if you can trigger this error on a clean install.

joshuami’s picture

Component: Group (group) » Code
Related issues: +#3126343: Scheduler needs to maintain its base fields properly

@kristiaanvandeneynde, I've been able to reproduce this error and it is definitely a lightning_workflow or lightning_scheduler issue depending on which module you are using. There is a patch in #3126343 that will unblock the update of group for anyone using lightning_workflow with its lightning_scheduler submodule. That patch will not work if you are using the lightning_scheduler module.

I wonder if closed duplicate would be a better status so that folks are sure to look at the root cause. I hate to change a closed status on a maintainer. :o)

joshuami’s picture

Issue summary: View changes
Status: Closed (cannot reproduce) » Closed (duplicate)
kristiaanvandeneynde’s picture

I wonder if closed duplicate would be a better status so that folks are sure to look at the root cause. I hate to change a closed status on a maintainer. :o)

Seems like the right call

vrwired’s picture

[error] Update failed: group_post_update_make_group_revisionable occurred in our case due to not having dropped the database before importing production

caesius’s picture

It is always the case that if a database update makes a schema change then the update will fail if you don't drop the dev database before importing production, so your scenario is not really specific to the bug that this issue addresses. Always drop your database before importing.

sam.foster’s picture

So I came across this issue when preparing to move from D8 to D9. I was updating contrib modules in order to prepare for that update.

Our build had standalone lightning_scheduler, and I couldn't get groups updated to 1.4 because of this issue.

I tried the usual Drush approaches to uninstalling the lightning_scheduler module but it wouldn't uninstall either so I resorted to this

https://drupal.stackexchange.com/questions/72927/manually-disable-a-module

and used the one liner to uninstall the lightning_scheduler module

then enabled it with drush ('drush pm-enable lightning_scheduler')

ran drush updb to see if all ok and it was

Now I am about to UAT the site and check it works as it should!

Sam

PS this was all on my local and before I do anything re deploying the codebase to our Acquia environments I'll be getting the database from there and running updates to see if this flushes out an issue I may still have

If anyone has had any other solutions to this issue that avoid what I did pls do speak up - this is not my preferred way to do things. Better when the just work right! ;-)

joseph.olstad’s picture

I had the same issue, we're getting rid of lightning.

In my case I actually had more luck removing lightning by using fake lightning modules that I generated with drush gen module.

once I used the fake lightning* modules I was able to complete the schema upgrade and then uninstall lightning but for each site will be different challenge if your custom modules require lightning you'll have to unravel that. Also lightning brings in some other modules you may need a composer require for those.

o_timoshchuk’s picture

StatusFileSize
new794 bytes

I had the same issue and found two empty revision tables in the database. To resolve it, I created a patch.

kanchamk’s picture

I updated the group module from 1.2 to 1.6 and got the below error. Any idea?

>  [notice] Update started: group_post_update_make_group_revisionable
>  [error]  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.tmp_2d4eecgroup_r__e3b0c44298' doesn't exist: INSERT INTO "tmp_2d4eecgroup_r__e3b0c44298" ("entity_id", "revision_id", "bundle", "delta", "langcode", "field_learning_path_duration_target_id") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array
> (
>     [:db_insert_placeholder_0] => 67
>     [:db_insert_placeholder_1] => 67
>     [:db_insert_placeholder_2] => learning_path
>     [:db_insert_placeholder_3] => 0
>     [:db_insert_placeholder_4] => de
>     [:db_insert_placeholder_5] => 630
> )
>  in Drupal\Core\Entity\Sql\SqlContentEntityStorage->saveToDedicatedTables() (line 1403 of C:\xampp\htdocs\opigno-composer\web\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php).
>  [error]  The entity update process failed while processing the entity type group, ID: 67.
>  [error]  Update failed: group_post_update_make_group_revisionable
joseph.olstad’s picture

@kanchamk, please make a backup of your dump file before trying this.

based on comment #25

drush sqlq 'drop table if exists groups_revision;';
drush sqlq 'drop table if exists groups_field_revision;';
kanchamk’s picture

StatusFileSize
new360.96 KB

@joseph, These tables groups_revision and groups_field_revision did not exist in the database in the first place even after upgrading the group module from 1.2 to 1.6. Attached screenshot for reference.
group tables

joseph.olstad’s picture

@kamchamk, if you look at my explanation , I'll repeat again what I did myself to fix this.

#24

In my case I actually had more luck removing lightning by using fake lightning modules that I generated with drush gen module.

once I used the fake lightning* modules I was able to complete the schema upgrade and then uninstall lightning but for each site will be different challenge if your custom modules require lightning you'll have to unravel that. Also lightning brings in some other modules you may need a composer require for those.

Before I elaborate on this explanation, please check to see if you're using any module who's name starts with "lightning" or "Lightning"

My go-to for a quick module verification is this:
drush pml | grep lightning -i
If you are unable to do this for some reason then use the web interface for Drupal.

kanchamk’s picture

Hi @joseph, I don't have any modules starting with lightning installed. FYI, I am using opigno_lms v3.2.7. Recently migrated opigno_lms from 3.1.0 to 3.2.7

joseph.olstad’s picture

This table: tmp_2d4eecgroup_r__e3b0c44298 is a strange one that I've never seen or heard of, is this expected by the hook_update? check the group.install code
which hook_update is failing?

joseph.olstad’s picture

Good luck on this @kamchamk , you may want to instead switch to group 2 or version 3 instead and try upgrading to those instead.
check the release notes.

kanchamk’s picture

@joseph, I can't update group module as opigno_lms has fixed its group dependency version to 1.6. This is failing in post_update function group_post_update_make_group_revisionable in group.post_update.php

joseph.olstad’s picture

The word "can't" doesn't exist in my Drupal vocabulary.

override opigno_lms in your composer.json file as follows:

Add a line to your require section
"drupal/group": "3.2.2 as 1.6",

or, for 2.x

"drupal/group": "2.2.2 as 1.6",

If it's the last item of the section, remove the trailing comma, otherwise you will need the comma

Then run composer up drupal/group

I'd suggest trying 3.2.2 first. We're using 3.2.2.

kanchamk’s picture

I was able to resolve this issue by doing the following:

  • Go to /admin/group/types/manage/learning_path/fields , here learning_path is my group type.
  • "Edit" every field and click on "Save" to update the field.
  • Run drush updb again. This error issue was resolved and now group fields are revisionable

@joseph, thank you for your help.

joseph.olstad’s picture

Very cool, thanks for the followup, that is good to know in case I come accross another project that needs upgrading your trick may come in handy.

firstlut’s picture

I am updating Opigno LMS, as well, and I tried the "edit fields" trick, and that merely changed the nature of the error. Then I got an error that the preUpdateEntityTypeSchema function in SqlContentEntityStorageSchema.php was getting mismatched arrays. There was one field that wasn't getting a corresponding revision field created.

I deleted the offending field for now just so I could move on, but I'll have to address it eventually.

agileadam’s picture

I too am having a similar issue to kanchamk, however resaving the learning path fields does not fix the issue. Following, while I work on it.

jwjoshuawalker’s picture

@firstlut What field was it for you?
Same issues here during Opigno 3.1.0 -> 3.2.7 upgrade. Group module going from 1.2 to 1.6.
It starts out as:
Column not found: 1054 Unknown column 'field_learning_path_duration_target_id' in 'INSERT INTO': INSERT INTO "tmp_3a2a85group_r__e3b0c44298"

Then, if I edit & save that field on the learning_path group type, it becomes this error when trying to updb:
ValueError: array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements in array_combine()

Stemming from: group/group.post_update.php(156) where:

group_post_update_make_group_revisionable() 
// calls:
$definition_update_manager->updateFieldableEntityType($entity_type, $field_storage_definitions, $sandbox);