This document attempts to detail the process of upgrading ambientimpact.com from Drupal 7 to Drupal 8.
The Upgrading to Drupal 8 documentation on Drupal.org is recommended reading before going any further as it explains many of the key concepts and the how and why of upgrading/migration.
There are a few important concepts to keep in mind:
- The migration process requires you to install a separate Drupal 8 site, rather than upgrading the Drupal 7 site in place. This makes it easier to compare sites side by side and allows you to run and roll back migrations multiple times.
- Drupal core's migration process currently requires that the new site be completely empty, without any content (nodes) created before the migration is run. Attempting to run migrations after even a single node has been created manually will cause errors. While it's theoretically possible to put together a custom workflow to migrate content into a site that already has user-created content, that's out of the scope of this document.
After installing a new Drupal 8 site, you'll need to add a connection to the legacy Drupal 7 database in your settings.php:
// The legacy, local Drupal 7 database to migrate from.
$databases['migrate_drupal7']['default'] = [
'database' => '',
'username' => '',
'password' => '',
'driver' => 'mysql',
'host' => '',
'port' => '',
];
You'll have to fill in the details for your database. If you're developing locally on Acquia DevDesktop like I did, here's what I used:
// The legacy, local Drupal 7 database to migrate from.
$databases['migrate_drupal7']['default'] = [
'database' => 'ambientimpact_drupal7_dev',
'username' => 'drupaluser',
'password' => '',
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => 33067,
];
Note the lack of a password - DevDesktop automatically sets up the
drupaluser user without a password, which is fine for local development
but should never be done for a site accessible over the internet.
The following core and contrib modules need to be installed:
- Drupal core's Migrate and Migrate Drupal
- Migrate Plus
- Migrate Tools
- Migrate File Entities to Media Entities
Additionally, the relevant modules from this repository need to be installed:
- Ambient.Impact - Migrate (
ambientimpact_migrate) - Ambient.Impact - Paragraphs migrate (
ambientimpact_paragraphs_migrate) - Ambient.Impact - Web migrate (
ambientimpact_web_migrate) - Ambient.Impact - Portfolio migrate (
ambientimpact_portfolio_migrate)
This section lists various resources used to build these working migrations in the hope that they'll be useful to others who are attempting migrations.
- Upgrading to Drupal 8
- Migrate API
- List of core Migrate process plugins
- List of process plugins provided by Migrate Plus
- Drupal core
- Migrate Plus
- Paragraphs
- Entity Reference Revisions (used by Paragraphs)
- Paragraphs: Migration templates for automated migration from Drupal 7 version [#2841593]
- Paragraphs: Field collections deriver and base migration [#2911244] (is for Drupal 7 field collections, but was useful to look at)
- Paragraphs: Migration plugin source for D7_Paragraph? [#2917749] (some resources linked in comments)
- Building a custom migration in Drupal 8 series on deninet.com; Part 4: Files and Content and Part 5: Paragraphs were especially useful in building custom migrations.
- Migrating Content References in Drupal 8 | Mediacurrent
- Migrating Paragraphs in Drupal 8 – Four Kitchens
- Drupal 7 to 8 Migration: Step by Step Notes | IAC Web Development Resources
- Drupal 7 to Drupal 8 Migration - 101 and Observations | Tanay Sai
- Custom Drupal-to-Drupal Migrations with Migrate Tools | Drupalize.Me
The following were not used in this migration but are listed because they may be useful for other migrations:
- A slick migration trick - convert columns to multi-value field with subfields
- Migration of CSV Data into Paragraphs | MTech
- Troubleshooting a Drupal 8 Migration | MTech
- Drupal 8 CSV Migration | U.Group - Advanced Technology & Creative Design
The migrations are broken down into several discrete groups requiring their own
workflows. Note that commands are in the Drush
9+ format, i.e. with colon (:)
characters; most can be run in Drush 8 by replacing the colon with a dash
(-).
Most of these migrations require the ambientimpact_migrate
module to be enabled. Before you enable it, you have to
provide the absolute path to the Drupal 7 root directory by editing the
source_base_path: '' line in
ambientimpact_migrate/config/install/migrate_plus.migration.d7_file_ambientimpact.yml.
Note that this path is the root of the Drupal 7 install, not containing the
sites/<site>/files path. If you've already enabled the module, uninstall
it, make the edit, and then install it again. Alternatively, you can install
ambientimpact_migrate and then edit the configuration manually using the
Devel module's Config editor.
All other migrations not listed here were handled using the migrations created by Drupal core's upgrade process; for example, various site settings and other basic stuff not requiring custom configuration and code.
Copy all relevant files from the Drupal 7 sites/<site>/files directory to
the Drupal 8 sites/<site>/files directory; the
sites/<site>/files/paragraphs directory holds images and animated GIFs for
web snippets, and the sites/<site>/files/project_images directory holds
portfolio project image files.
Once files are copied, run the following command:
drush migrate:import d7_file_ambientimpact
There doesn't seem to be an out of the box way to migrate specific vocabularies, so the following will migrate all vocabularies:
drush migrate:import d7_taxonomy_vocabulary
Then, you can import all the terms in the web tags and project categories vocabularies:
drush migrate:import d7_taxonomy_term:web_tags,d7_taxonomy_term:project_categories
Enable the ambientimpact_porfolio_migrate
module and then run:
drush migrate:import d7_node_project
Install the
ambientimpact_paragraphs_migrate
and ambientimpact_media modules.
Make sure to run d7_file_ambientimpact.
Apply the LoadEntity process plug-in patch for Migrate Plus.
Then, run the following:
drush migrate:import d7_file_entity_vimeo,d7_file_entity_youtube,d7_paragraph_animated_gifs,d7_paragraph_code,d7_paragraph_images,d7_paragraph_text,d7_paragraph_video
See the
ambientimpact_paragraphs_migrate
module for more information.
Install the ambientimpact_web_migrate
module and then run the following:
drush migrate:import d7_node_web_snippet
This is detailed in the ambientimpact_paragraphs_migrate
module
This is a quick and dirty reference used during development. This assumes public files have been copied over, all modules have been enabled, and vocabularies already exist or have been migrated.
Note that Migrate Manifest could have been used to automate most of this in hindsight.
Absolutely everything:
drush migrate:import d7_file_ambientimpact,d7_file_entity_vimeo,d7_file_entity_youtube,d7_taxonomy_term:web_tags,d7_taxonomy_term:project_categories,d7_node_project,d7_paragraph_animated_gifs,d7_paragraph_code,d7_paragraph_images,d7_paragraph_text,d7_paragraph_video,d7_node_web_snippet
drush migrate:duplicate-file-detection d8_paragraph_animated_gifs_media_step1
drush migrate:duplicate-file-detection d8_paragraph_images_media_step1
drush migrate:import d8_paragraph_animated_gifs_media_step1,d8_paragraph_animated_gifs_media_step2,d8_paragraph_images_media_step1,d8_paragraph_images_media_step2
Just portfolio projects:
drush migrate:import d7_file_ambientimpact,d7_taxonomy_term:project_categories,d7_node_project
Just web snippets:
drush migrate:import d7_file_ambientimpact,d7_file_entity_vimeo,d7_file_entity_youtube,d7_taxonomy_term:web_tags,d7_paragraph_animated_gifs,d7_paragraph_code,d7_paragraph_images,d7_paragraph_text,d7_paragraph_video,d7_node_web_snippet
drush migrate:duplicate-file-detection d8_paragraph_animated_gifs_media_step1
drush migrate:duplicate-file-detection d8_paragraph_images_media_step1
drush migrate:import d8_paragraph_animated_gifs_media_step1,d8_paragraph_animated_gifs_media_step2,d8_paragraph_images_media_step1,d8_paragraph_images_media_step2
Absolutely everything:
drush migrate:rollback d8_paragraph_animated_gifs_media_step2,d8_paragraph_animated_gifs_media_step1,d8_paragraph_images_media_step2,d8_paragraph_images_media_step1,d7_node_web_snippet,d7_paragraph_animated_gifs,d7_paragraph_code,d7_paragraph_images,d7_paragraph_text,d7_paragraph_video,d7_node_project,d7_file_entity_vimeo,d7_file_entity_youtube,d7_file_ambientimpact,d7_taxonomy_term:web_tags,d7_taxonomy_term:project_categories
Just portfolio projects:
drush migrate:rollback d7_node_project,d7_taxonomy_term:project_categories,d7_file_ambientimpact
Just web snippets:
drush migrate:rollback d8_paragraph_animated_gifs_media_step2,d8_paragraph_animated_gifs_media_step1,d8_paragraph_images_media_step2,d8_paragraph_images_media_step1,d7_node_web_snippet,d7_paragraph_animated_gifs,d7_paragraph_code,d7_paragraph_images,d7_paragraph_text,d7_paragraph_video,d7_file_entity_vimeo,d7_file_entity_youtube,d7_file_ambientimpact,d7_taxonomy_term:web_tags