Content migration from Drupal 7 with Migrate Upgrade

We will assume here a content migration without the configuration and see how to generate most of our migration templates.
In most cases the content model will change in Drupal 8 so we will need a partial migration, assuming that the site building is done manually on the Drupal 8 site.

Most migration templates can be generated by the Migrate Upgrade module.
While migration templates can be generated for configuration and content, we will mainly focus on the content templates here, then tweak them for the new content model.

Prepare the Drupal 8 environment

Reference the Drupal 7 database

In the settings file, add a reference to the Drupal 7 database.

// The Drupal 7 database connection details.
$databases['drupal7']['default'] = [
  'database' => 'drupal7',
  'username' => 'root',
  'password' => 'root',
  'prefix' => '',
  'host' => '127.0.0.1',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
];

Contributed modules

Install in Drupal 8 all the contributed modules that should be included in the migration. If they have a migration path, they will be included while exporting the configuration with Migrate Upgrade.
In this case, configuration templates might be copied later on.

Migrate Upgrade

Install

composer require drupal/migrate_upgrade
drush en migrate_upgrade

Extract the configuration

drush migrate:upgrade --legacy-db-key drupal7 --legacy-root sites/default/files --configure-only

We will then export the configuration in a /tmp directory and copy it into our custom module.

drush config:export --destination=/tmp/migrate

cp /tmp/migrate/migrate_plus.migration.* /tmp/migrate/migrate_plus.migration_group.migrate_*.yml /web/modules/custom/my_migration/tmp

Select the migration templates

We didn't copied the config files into the install directory to allow a selection of the needed templates.

Pick the needed templates and copy them into the config/install directory of your custom module.
Make the adaptations for your new content model, implement hooks, process plugins, ...

Check the status

drush ms --group migrate_drupal_7

Import

drush mim --group migrate_drupal_7

Resources