table 'group_relationship' already exists

Created on 20 April 2023, over 1 year ago
Updated 20 November 2023, about 1 year ago

I'm having trouble upgrading. Here's my flow:

  • installed the flexible_permissions module
  • composer update from Group 1.5 to 2.0
  • run Drush updb

I get this error:

 -------- ----------- --------------- ----------------------------------------- 
  Module   Update ID   Type            Description                              
 -------- ----------- --------------- ----------------------------------------- 
  group    9201        hook_update_n   9201 - Update class name and handler     
                                       class names for group_content_type.      
  group    9202        hook_update_n   9202 - Update class name and handler     
                                       class names for group_content.           
  group    9203        hook_update_n   9203 - Update group_content DB table,    
                                       fields and indexes.                      
  group    9204        hook_update_n   9204 - Remove the 'bypass group access'  
                                       permission from all roles.               
  group    9205        hook_update_n   9205 - Convert group roles with the      
                                       'administer group' permission to admin   
                                       roles.                                   
  group    9206        hook_update_n   9206 - Convert synchronized group roles  
                                       to new scope and target_role structure.  
  group    9207        hook_update_n   9207 - Convert default group roles to    
                                       new scope and target_role structure.     
  group    9208        hook_update_n   9208 - Convert user created group roles  
                                       to new scope and target_role structure.  
  group    9209        hook_update_n   9209 - Remove label and description      
                                       from relationship types.                 
  group    9210        hook_update_n   9210 - Introduce the                     
                                       group_config_wrapper entity type.        
 -------- ----------- --------------- ----------------------------------------- 


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

>  [notice] Update started: group_update_9201
>  [notice] Update completed: group_update_9201
>  [notice] Update started: group_update_9202
>  [notice] Update completed: group_update_9202
>  [notice] Update started: group_update_9203
>  [error]  Exception thrown while performing a schema update. Cannot rename 'tmp_8e7702group_relationship' to 'group_relationship': table 'group_relationship' already exists. 
>  [error]  Update failed: group_update_9203 
 [error]  Update aborted by: group_update_9203 
 [error]  Finished performing updates. 

I tried restoring my prod database to my dev environment and I still get the same error. I've never had Group 2.0 on my prod env. Why would the table already exist?

💬 Support request
Status

Fixed

Version

2.0

Component

Code

Created by

🇩🇪Germany markdc Hamburg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @markdc
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    No clue, but try deleting it and then start over. You should still have a group_content table, is that the case?

  • 🇪🇸Spain SalvadorP Alicante

    Hello,

    Same problem with the drupal 9.5 I'm working with, we are using the group version 1.5 and when trying to upgrade to 2.1 we receive a similar error.

    Also gives a different one, complaining about that the "entity:group_content_type" plugin does not exist.

    Here is the log:

      group    9203        hook_update_n   9203 - Update group_content DB table, fields and indexes.
      group    9204        hook_update_n   9204 - Remove the 'bypass group access' permission from all roles.
      group    9205        hook_update_n   9205 - Convert group roles with the 'administer group' permission to admin roles.
      group    9206        hook_update_n   9206 - Convert synchronized group roles to new scope and target_role structure.
      group    9207        hook_update_n   9207 - Convert default group roles to new scope and target_role structure.
      group    9208        hook_update_n   9208 - Convert user created group roles to new scope and target_role structure.
      group    9209        hook_update_n   9209 - Remove label and description from relationship types.
      group    9210        hook_update_n   9210 - Introduce the group_config_wrapper entity type.
     -------- ----------- --------------- -----------------------------------------
    
    
     // Do you wish to run the specified pending updates?: yes.
    
    >  [notice] Update started: group_update_9203
    >  [error]  Exception thrown while performing a schema update. Cannot rename 'tmp_9ac9a9group_relationship' to 'group_relationship': table 'group_relationship' already exists.
    >  [error]  Update failed: group_update_9203
    >
    > In DiscoveryTrait.php line 53:
    >
    >   The "entity:group_content_type" plugin does not exist. Valid plugin IDs for
    >    Drupal\rest\Plugin\Type\ResourcePluginManager are: dblog, file:upload, ent
    >   ity:block, entity:block_content, entity:block_content_type, entity:comment_
    >   type, entity:comment, entity:consumer, entity:contact_message, entity:conta
    >   ct_form, entity:editor, entity:print_engine, entity:feeds_feed, entity:feed
    >   s_subscription, entity:feeds_feed_type, entity:field_config, entity:field_s
    >   torage_config, entity:file, entity:filter_format, entity:group, entity:grou
    >   p_content, entity:group_type, entity:group_config_wrapper, entity:group_rol
    >   e, entity:image_style, entity:key, entity:key_config_override, entity:confi
    >   gurable_language, entity:language_content_settings, entity:media, entity:me
    >   dia_type, entity:node_type, entity:node, entity:openid_connect_client, enti
    >   ty:paragraphs_type, entity:paragraph, entity:paragraphs_library_item, entit
    >   y:path_alias, entity:responsive_image_style, entity:rest_resource_config, e
    >   ntity:search_page, entity:shortcut, entity:shortcut_set, entity:menu, entit
    >   y:action, entity:taxonomy_vocabulary, entity:taxonomy_term, entity:tour, en
    >   tity:user_role, entity:user, entity:workflow, entity:menu_link_content, ent
    >   ity:pathauto_pattern, entity:view, entity:date_format, entity:base_field_ov
    >   erride, entity:entity_view_display, entity:entity_form_display, entity:enti
    >   ty_view_mode, entity:entity_form_mode, user_registration
    >
    >
    
    In ProcessBase.php line 155:
    
      Output is empty.
    
    

    The 9200, 9201 and 9202 were run previously, properly, I was going step by step trying to catch were it fails, and it's on the 9203 update step.

    At first I thought it was some problem with the dev database so I used a clean copy of other environment but with no luck.

    Then I tried to restore the database, erase all the code and redownload it with composer.
    Restored the database, checked that the group_relationship table does not exists, then dropped the temporary tables, clear the cache tables and then run the drush updb, and got the same error.

    I'm searching for a solution or a way to upgrade to v2, but with no luck for now.
    Has this or anything similar happened to you?

  • 🇺🇸United States daletrexel Minnesota, USA

    @markdc @SalvadorP (or anyone else coming to this issue with the same problem):

    One thing that can trip people up (including myself!) is that restoring a database from backup may leave bits of the previous database hanging around, depending on the tools you use.

    Reading a database backup from a mysql dump will normally drop individual tables before restoring the from the backup, but tables not in the backup won't be touched. So, if you're iterating through the Group upgrade process and got past the point where the update creates a new table in the database, that table will remain if you don't clear out the entire database (or at least that new table) before re-importing from a previous backup for your next round of testing.

    For example, if you're used to using drush sql:dump to generate backups, and something like drush sql:cli < backupFile.sql to re-import a previous backup, this could leave newly-generated tables in the database to confuse you.

    Drush has a handy drush sql:drop command to drop and re-create the database, clearing out ALL tables, before you import a backup. Some local development tools like DDEV also have database import tools that clear out old tables before importing a backup, without having to do a two-step process (like you have to do with drush).

    If you're still seeing table-already-exists errors after adding this step to your restore process (and you're sure the table hasn't snuck into your backup from a previous upgrade attempt!), then feel free to update here. I've been working on Group 1.5 to 2.x upgrades pretty heavily and the only times I've seen this error it has been my own fault. But that doesn't mean there isn't a real problem for certain scenarios.

  • 🇪🇸Spain SalvadorP Alicante

    @DaleTrexel, thank you very much for the information and the heads up on leftover tables.

    Restored a backup from other environment and used drush sql:drop to make sure that only the proper tables were imported and after the DB restore all the updates worked!

    The downside of this is that I'm still getting the error "entity:group_content_type".
    I'm investigating if it's something related to my drupal installation or a content type issue, not sure.

    Did you ever see that error on your upgrades?

    Here is the output of the ./drush updb after upgrading to groups v2:

    ./drush updb -y
     -------- ----------- --------------- -----------------------------------------
      Module   Update ID   Type            Description
     -------- ----------- --------------- -----------------------------------------
      group    9200        hook_update_n   9200 - Install required
                                           flexible_permissions contrib module.
      group    9201        hook_update_n   9201 - Update class name and handler
                                           class names for group_content_type.
      group    9202        hook_update_n   9202 - Update class name and handler
                                           class names for group_content.
      group    9203        hook_update_n   9203 - Update group_content DB table,
                                           fields and indexes.
      group    9204        hook_update_n   9204 - Remove the 'bypass group access'
                                           permission from all roles.
      group    9205        hook_update_n   9205 - Convert group roles with the
                                           'administer group' permission to admin
                                           roles.
      group    9206        hook_update_n   9206 - Convert synchronized group roles
                                           to new scope and target_role structure.
      group    9207        hook_update_n   9207 - Convert default group roles to
                                           new scope and target_role structure.
      group    9208        hook_update_n   9208 - Convert user created group roles
                                           to new scope and target_role structure.
      group    9209        hook_update_n   9209 - Remove label and description
                                           from relationship types.
      group    9210        hook_update_n   9210 - Introduce the
                                           group_config_wrapper entity type.
     -------- ----------- --------------- -----------------------------------------
    
    
     // Do you wish to run the specified pending updates?: yes.
    
    >  [notice] Update started: group_update_9200
    >  [notice] Update completed: group_update_9200
    >  [notice] Update started: group_update_9201
    >  [notice] Update completed: group_update_9201
    >  [notice] Update started: group_update_9202
    >  [notice] Update completed: group_update_9202
    >  [notice] Update started: group_update_9203
    >  [notice] Update completed: group_update_9203
    >  [notice] Update started: group_update_9204
    >  [notice] Update completed: group_update_9204
    >  [notice] Update started: group_update_9205
    >  [notice] Update completed: group_update_9205
    >  [notice] Update started: group_update_9206
    >  [notice] Update completed: group_update_9206
    >  [notice] Update started: group_update_9207
    >  [notice] Update completed: group_update_9207
    >  [notice] Update started: group_update_9208
    >  [notice] Update completed: group_update_9208
    >  [notice] Update started: group_update_9209
    >  [notice] Update completed: group_update_9209
    >  [notice] Update started: group_update_9210
    >  [notice] Update completed: group_update_9210
    >
    > In DiscoveryTrait.php line 53:
    >
    >   The "entity:group_content_type" plugin does not exist. Valid plugin IDs for
    >    Drupal\rest\Plugin\Type\ResourcePluginManager are: dblog, file:upload, ent
    >   ity:block, entity:block_content, entity:block_content_type, entity:comment_
    >   type, entity:comment, entity:consumer, entity:contact_message, entity:conta
    >   ct_form, entity:editor, entity:print_engine, entity:feeds_feed, entity:feed
    >   s_subscription, entity:feeds_feed_type, entity:field_config, entity:field_s
    >   torage_config, entity:file, entity:filter_format, entity:group, entity:grou
    >   p_content, entity:group_type, entity:group_config_wrapper, entity:group_rol
    >   e, entity:image_style, entity:key, entity:key_config_override, entity:confi
    >   gurable_language, entity:language_content_settings, entity:media, entity:me
    >   dia_type, entity:node_type, entity:node, entity:openid_connect_client, enti
    >   ty:paragraphs_type, entity:paragraph, entity:paragraphs_library_item, entit
    >   y:path_alias, entity:responsive_image_style, entity:rest_resource_config, e
    >   ntity:search_page, entity:shortcut, entity:shortcut_set, entity:menu, entit
    >   y:action, entity:taxonomy_vocabulary, entity:taxonomy_term, entity:tour, en
    >   tity:user_role, entity:user, entity:workflow, entity:menu_link_content, ent
    >   ity:pathauto_pattern, entity:view, entity:date_format, entity:base_field_ov
    >   erride, entity:entity_view_display, entity:entity_form_display, entity:enti
    >   ty_view_mode, entity:entity_form_mode, patrolplan_resource, user_registrati
    >   on
    >
    >
    
    In ProcessBase.php line 155:
    
      Output is empty.
    
    
  • 🇪🇸Spain SalvadorP Alicante

    Finally could update, the problem I had with the "entity:group_content_type", was related to an old REST Resource configuration.
    After removing that I could finishe the upgrade/migration from 1.5 to 2.1 without errors.

  • 🇩🇪Germany markdc Hamburg

    @DaleTrexel
    Thank you. You were exactly right about the database tables. Doing a clean import after drop allowed everything to update.

  • Status changed to Fixed about 1 year ago
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Cool, marking as resolved then.

  • Status changed to Active about 1 year ago
  • Status changed to Fixed about 1 year ago
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Please don't do this, open a new issue if you have one.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024