Skip to content

Instantly share code, notes, and snippets.

@travisbutterfield
Last active July 30, 2021 14:27
Show Gist options
  • Save travisbutterfield/f7d62342c545d84ea73e07464a53d9cc to your computer and use it in GitHub Desktop.
Save travisbutterfield/f7d62342c545d84ea73e07464a53d9cc to your computer and use it in GitHub Desktop.

Connecting separate Lando containers for migration

Using some of the information from this article, and information from a few other sources, I have come up with a procedure for connecting two separate local Lando containers for Drupal 7 to Drupal 9 migration work.

  1. Create your Drupal 7 container from the source. In this case, we will be using a Pantheon-based website.
  2. Create your new Webspark 2 (Drupal 9) site in Pantheon.
  3. Install and enable modules in the new D9 site. (If you want to migrate content from D7 that is related to a module in any way, you will have to install that module in your D9 site, or the Migrate API won’t know to include it.)
    • Use Composer to require modules: lando composer require 'drupal/migrate_plus:^5.1' 'drupal/migrate_tools:^5.0' 'drupal/migrate_upgrade:^3.2'
    • Enable modules using Drush (this includes some core and migration modules, but you can enable whatever you need): lando drush --yes en migrate_drupal migrate_plus migrate_tools migrate_upgrade block_content comment contact datetime file image link options path taxonomy text ckeditor editor field_ui menu_link_content menu_ui toolbar views views_ui media media_library layout_builder layout_discovery responsive_image datetime_range telephone
  4. Add drupal7 database connection info to the web/sites/default/settings.php or web/sites/default/settings.local.php file in the D9 site:
$databases['migrate']['default'] = array (
   'database' => 'db',
   'username' => 'db',
   'password' => 'db',
   'prefix' => '',
   'host' => 'database.<sitename>.internal',
   'port' => 3306,
   'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
   'driver' => 'mysql',
 );
  1. Clear caches. Then verify that Drupal 9 can connect to the Drupal 7 database: lando drush cr; lando $(drush sql-connect --database=migrate)
  2. Run migrate:upgrade --configure-only to get the migration YAML files: lando drush --yes migrate:upgrade --legacy-db-key='migrate' --legacy-root='http://<sitename>.lndo.site' --configure-only
  3. Export the configuration to code: lando drush --yes config:export
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment