Skip to content

Instantly share code, notes, and snippets.

@labboy0276
Last active August 16, 2018 19:29
Show Gist options
  • Save labboy0276/ded093b7644bb1a29e57728cc2a89ea2 to your computer and use it in GitHub Desktop.
Save labboy0276/ded093b7644bb1a29e57728cc2a89ea2 to your computer and use it in GitHub Desktop.
Pantheon to Pantheon D8 Migration

Pantheon to Pantheon Migration Setup

  1. SFTP a file called secrets.json to your D8's files/private folder.
    • Just put this in the file to make a legit json file: {}
  2. In your D8 site's settings.php put this at the bottom:
# When on Pantheon, connect to a D7 database.
$migrate_settings = __DIR__ . "/settings.migrate-on-pantheon.php";
if (file_exists($migrate_settings) && isset($_ENV['PANTHEON_ENVIRONMENT'])) {
 include $migrate_settings;
}
  1. Create a file called settings.migrate-on-pantheon.php in your D8 sites/default folder and put this in it:
<?php
 
$secretsFile = $_SERVER['HOME'] . '/files/private/secrets.json';
if (file_exists($secretsFile)) {
  $secrets = json_decode(file_get_contents($secretsFile), 1);
}
if (!empty($secrets['migrate_source_db__url'])) {
  $parsed_url = parse_url($secrets['migrate_source_db__url']);
  if (!empty($parsed_url['port']) && !empty($parsed_url['host']) && !empty($parsed_url['pass'])) {
    $databases['migrate']['default'] = array (
      'database' => 'pantheon',
      'username' => 'pantheon',
      'password' => $parsed_url['pass'],
      'host' => $parsed_url['host'],
      'port' => $parsed_url['port'],
      'driver' => 'mysql',
      'prefix' => '',
      'collation' => 'utf8mb4_general_ci',
    );
  }
}
  1. Install Terminus and the Terminus Secrets Plugin
  2. Run these commands on your local machine:
export D7_MYSQL_URL=$(terminus connection:info --field=mysql_url D7-PANTHEON-SITE.PANTHEON-ENV)
terminus secrets:set D8-PANTHEON-SITE.PANTHEON-ENV migrate_source_db__url $D7_MYSQL_URL
terminus remote:drush D8-PANTHEON-SITE.PANTHEON-ENV -- migrate-upgrade --legacy-db-key=migrate --configure-only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment