Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The first issue I ran into is that the migrate plugin looks for rows in the field_group db table which most of the time will not be populated if the Drupal 7 site is using Features. Is there a way around this issue?
Also, when I re-save the "manage fields" tab for the content type it will force data back into the field_group database table which lets the migration run successfully but even after that I don't see a field group on the form display page (not even disabled).
Comment | File | Size | Author |
---|---|---|---|
#6 | Screenshot from 2021-03-04 15-47-34.png | 57.19 KB | kevinquillen |
#6 | Screenshot from 2021-03-04 15-35-13.png | 303.89 KB | kevinquillen |
Comments
Comment #2
drupalninja99 CreditAttribution: drupalninja99 commentedComment #3
bob.hinrichs CreditAttribution: bob.hinrichs commentedI am kind of surprised this is not a very popular issue, but I've had problems locating people writing about it until now. It is real and I encountered the same, as I'm sure thousands have, no? Field groups are a super-important part of drupal, yet it appears you can't migrate them if you use features, unless you re-save everything. I feel like there has to be a good solution somewhere, especially since this same problem can occur for other "features" stored in features.
Comment #4
drupalfan2 CreditAttribution: drupalfan2 as a volunteer commentedIs there still no solution for migrations field groups to Drupal 8?
Comment #5
kevinquillen CreditAttribution: kevinquillen commentedI just ran into this, solution incoming...
Comment #6
kevinquillen CreditAttribution: kevinquillen commentedI encountered this same issue. I had about 40 field groups that were only defined by Features and unaware they would not migrate.
I solved it by grabbing them and dumping them into the legacy database before running the Drupal 7 -> 9 upgrade.
First:
With that in place, create a custom module:
The gist of it is, PHP will get an array of .field_group.inc files from all the features and loop them, calling their field_group info hooks that return all the group definitions. Then use a merge query to insert them into the legacy databases "field_group" table. Since 'identifier' is used as a key, overwriting whats in the database should not be an issue since it is a unique key and likely doesn't exist. merge() just makes it easier to iterate or start over - you can use insert() too if you want to start fresh each time.
When installing the module, all the field group info hooks are invoked and their arrays are turned into database records:
With the groups inserted into the database, running the Drupal 7 -> Drupal 9 migration brought all field groups in. Example form:
If you don't want to insert into the legacy database, you can do it in your Drupal 9 database too (but you would need to write a migration plugin later to insert those records after the main migration has executed). Just add a schema hook to your custom module:
and get a normal database connection in the install function. After that you'd need to wire up a migration and source plugin to read this table into field_group. Either way will get you there.
Reconfiguring all of them would have taken me probably a day, this only took an hour to write.
Comment #7
kevinquillen CreditAttribution: kevinquillen commentedThis can probably be worked into field_group_migrate somehow as a new feature - leaving it up for discussion!
Comment #8
kevinquillen CreditAttribution: kevinquillen commentedComment #9
alisonWow, I was so so so so confused as to why four content types' field groups had migrations and no others! (because, Features were maintained for a while after this site was built but not forever, so there are content types and stuff with outdated or zero features)
Thank you everyone on this thread for sharing, and thank you @kevinquillen for the solution share! -- I haven't tried that part out yet, we're in a discovery phase, but I'm adding this to my notes for when we get to implementation.
Comment #10
kevinquillen CreditAttribution: kevinquillen commentedI've used the above trick a few times since then, YMMV.
Comment #11
alison@kevinquillen What's the reason for putting the features modules into the Drupal 9 site codebase? I'm missing where/how that part fits in.
Comment #12
alisonOH! Never mind, I see it now!!
Comment #13
kevinquillen CreditAttribution: kevinquillen commentedThey only exist so PHP can read the definitions of them in, in order to create the database records needed for the migration to pick them up.
Comment #14
alisonThank you! -- in case it helps anyone else who stops by this thread, my process for using the generated migrations was (and idk if this is best / correct, but it ended up working for me):
TL;DR: Run the field group migrations after field, field_instance, and field_instance_widget_settings migrations.
^^I missed field_instance_widget_settings at first, and almost all my field groups were "there" but empty! -- now, I see how/why.
More specifically, this was my order of things:
Comment #15
alisonI came across a couple other "site building things" that don't migrate smoothly / out-of-the box due to not being in the source site database when they're in Features (image styles, views), and posted about it here:
https://www.drupal.org/forum/support/upgrading-drupal/2024-01-24/upgradi...
Mainly, I'm just sharing in case it's helpful to others, but if anyone's run into other "site building things" that behave like that, I hope you'll comment on the Forum thread!