Problem/Motivation
In the issue https://www.drupal.org/project/group/issues/3318375#comment-14937415, the process for updating from version 2 to version 3 is discussed. The recommended processes is to perform a content migration.
For small sites, this approach may be feasible, but when dealing with multisites, this operation can be very costly. To avoid the update of a module requiring this amount of time and resources, we are exploring other options that would avoid the need for a migration.
We have created a script that does the following:
- Renames the table "group_content__group_roles" to "group_relationship__group_roles" in the database.
- Update configuration values: The script utilizes the "config.factory" service to update the configuration values and parameters related to the machine names "group_content", "group_content_type" and "group.content_type" replacing them with "group_relationship" and "group_relationship_type" and "group.relationship_type".
- Rename configuration objects: Additionally, the script renames the configuration objects that were created based on the machine names.
- Clear caches: After the modifications are made, the script clears the caches to ensure the changes take effect.
- Export configuration.
At the moment, we have performed these steps, and although after carrying out these actions, the Groups module appears to be functioning correctly, the Drupal Status Report shows that the "Group Relationship" and "Group Relationship Type" entities need to be installed.
This is due to the schema not being updated. However, we are currently investigating how to solve this issue.
Is this an appropriate approach?
Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | GroupUpgradeHelp.txt | 4.96 KB | hitchshock |
| #15 | group2to3config.sh_.txt | 442 bytes | geek-merlin |
| #6 | UpdateGroupsV3.txt | 4.15 KB | lpeidro |
Comments
Comment #2
lpeidro commentedComment #3
tunicWould be great to have the script posted so others can evaluate it.
Comment #4
kristiaanvandeneyndeBest approach would be to copy your website, remove all group related entities and uninstall group on the new copy, then update the code to 3.0.x on the new copy and finally reinstall Group and migrate your group related content from the old site to the new copy using the migrate module.
Comment #5
tunicWe are aware of what is said at #3318375: Create official instructions for Group 2.x to 3.x migration. However, with all my respect, we think the best approach is having an upgrade path from major version to major version. That's what we are trying here and I would really appreciate comments on this approach.
Comment #6
lpeidro commentedHello @Tunic:
This script is a proof of concept at maybe is not working in every project.
It executes the action set in the description of this issue:
It is a simple PHP class that I upload with the extensión txt: Helper Class
Thanks.
Comment #7
mnico commentedHello! A few months ago I had to perform this update on a few projects. From that experience I have created a more generic module for this task and have just published it here. I hope it can help you, I don't know if it would work on all sites (I don't know if there are other configurations that are not being migrated properly).
Instructions on how to use it are in the module's README.md file.
Regards
Comment #8
kristiaanvandeneynde@#5, #6, #7: The reason I did not provide an upgrade path is that I first had one but deemed it unsafe as there are simply too many things we cannot predict and we might leave people with a broken website.
Installing a clean v3 on a website and then migrating your v2 data into said site is always safe because your entity schema, fields, etc. are already in place and you're making sure the incoming data is correct.
You're free to use any module or code to try and upgrade directly, but please keep in mind that you might very well break your website in ways that might not immediately be apparent and therefore cause vague bug reports later on.
Comment #9
tunicThanks for your message on #8. Indeed, there are risks on using the upgrade path described here. If we do, we'll double check any bug found later to be sure it's from the module and not from the upgrade path used, we would like to have the issue queue clean of spurious errors.
I would like to ask a question. Eventually, there will be Group 4 release. Do you think it is possible there will be an upgrade path without migrating or do you think any Group 2.x site will need that copy-and-migrate upgrade path sooner or later?
#7, thanks for that link, we'll check it as well, and thanks for contributing it!
Comment #10
heddnI hope that an upgrade path from v2 to v4 will be possible.
Comment #11
kristiaanvandeneyndeMaybe by then core has better support for this type of thing, but for now it's really hard to rename an entity type. I had an upgrade path that took care of the definitions, field definitions and views and it still broke in various ways because of how hard it is to do this properly.
The good news is that v4 is probably going to take years to land, so you'll have plenty of time to enjoy the v2/v3 API and if the time does come to move from v2 to v4, we'll hopefully have some (sponsored?) documentation and tools to help you migrate by then.
Comment #12
SlayJay commentedany update on the "Group Relationship" and "Group Relationship Type" entities need to be installed issue?
I'm working on our site's D9 to D10 upgrade and this error message is one of our lingering outliers.
edit: Nevermind, For anyone else having this issue that comes across this issue thread, running drush entup fixed it for me.
Comment #13
somebodysysop commentedI know this is a composer question, but I just finally got to Group 2.2 after nearly since the first effort. In reading about what it takes to go from 2.x to 3.x, I'm terrified.
Currently, my composer settings want to automatically upgrade me from Group 2.2.0 to 3.2.0. How can I change my composer settings to not allow any automatic upgrade to 3.x?
I know this probably isn't the place for this, but I expect everybody here knows how to do it.
Comment #14
kristiaanvandeneyndeYou can stay on 2.2 for quite a long time, so don't worry too much about it. When the time is due to migrate to v3, which is when v4 comes out, I hope to have found a sponsor to help us write the documentation and perhaps helper module to assist people in making the upgrade.
Comment #15
geek-merlinAnother story to share:
- Have a site with huge sitebuilding, but no content (it's not yet in production)
A
drush site-install --existing-configfails because not only DB tables changed, but also a lot of config names.What i did and encountered:
- Created a bash script that changes all names in config/sync directory (attached)
- After running that on my config, i tried
drush site-install --existing-config- That had some issues
- Of course, name changes like
group_content_type_ad6738256f30d => group_relationship_type_ad6738256f30dbroke the import, because "32 character limit"- Also i had errors like "The content relationship plugin X could not be found". I cross-checked, but no idea why.
- In the end, i took the name-changed config, and deleted all content_relationship_type config. It only took 10 minutes to recreate them.
Comment #16
hitchshockA solution #6 is pretty good for me.
I just updated it a bit:
- it's better to use regex patterns to search and replace values
- sometimes we need also to update config keys (not only values)
- it's not required to update IDs of the Relationship Types. We can keep them to prevent possible errors with IDs mentioned in #15
Example how to use it:
drush ev "\Drupal::classResolver(\Drupal\my_module\GroupUpgradeHelp::class)->update();"And of course, you need to update your custom code:
- group_content -> group_relationship
- group_content_type -> group_relationship_type
Comment #17
kristiaanvandeneyndeMake sure to keep an eye on #3440222: Try to provide an upgrade path from 2.x.x to 3.x.x
Comment #18
dabley commentedThis now seems to be resolved by #3440222: Try to provide an upgrade path from 2.x.x to 3.x.x - as described in https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib... ?