Getting down to the nitty-gritty of migration

Having eventually got my new VM up and running, I ended up down another rabbit hole for a little while. It took me longer than it should have done to figure out that configuration can be included in an installation profile. Having seen an issue on drupal.org, I got the idea into my head that I needed to mess about with the config directory, or use the Configuration installer profile. Thankfully the reality was much simpler.

As is so often the case, the way I figured it out was by looking at the source code of something that did work - in this instance the standard installation profile in core revealed that all the config files should be in the config/install directory. If I find any other confusing or unintuitive things like this, I'll try to update the documentation on drupal.org, as well as making some notes here.

It feels like a common problem with a lot of code that the documentation isn't in sync with the code. It's not just an issue with open source, but given that a lot of developers are reluctant to write documentation when they're getting paid for it, it's hardly surprising that there's a real need for more people to contribute to documentation.

Once that was out of the way I was able to start poking about with the actual migration. I've had a little bit of experience with migration in Drupal 6 and 7, although not as much as some of my old colleagues, and the migrate_example module was again helpful for figuring out how it all fits together.

It's tricky because a lot of the migrations depend on other migrations, and I want to manipulate the data on the way in so that it works with slightly different field names. The tutorial by Cheppers is the most helpful article I've found. Here's the basic workflow that I've been using so far:

  1. Edit settings.php to include the old database connection
  2. Run migrate-upgrade to get the migrations
  3. Export the site configuration
  4. Put the exported migration definitions in to the config/install directory of your custom module
  5. Tweak the migration definitions:
    1. Define a migration group: migration_group: gall that defines the database source
    2. remove database_state_key: migrate_upgrade_6 from the migrations
  6. Re-install the site using the installation profile
  7. Check the migration status drush ms
  8. Run the migrations: drush mi --all - for The Gallery Guide this takes a long time
  9. Try changing the prepareRow function in the migration class
  10. Re-run individual migrations to test : drush mi d6_node__gallery --update

At the moment one of the migrations is choking on a problem in core/lib/Drupal/Core/Utility/LinkGenerator.php:

Error: Unsupported operand types in /var/www/drupalvm/drupal/core/lib/Drupal/Core/Utility/LinkGenerator.php, line 152
All tags