I've found some nice example to store the database credentials in settings.php as follow:

$databases['migrate']['default'] = array (
  'driver' => 'mysql',
  'database' => 'drupal6',
  'username' => 'root',
  'password' => 'root',
  'host' => '127.0.0.1',
  'port' => '3306',
  'prefix' => '',
);

Example:
https://drupal.org/node/1810122

Any way to integrate this feature into Migrate module?

Comments

kars-t’s picture

Status: Active » Closed (works as designed)

Hi

maybe I don't understand your feature request but what you describe is already possible with the current state of migrate. You can easily add multiple sources to your settings.php.

kenorb’s picture

I'm using Migrate with mix of migrate_d2d module.

As far as I know the current version keeps the db credentials in migrate_group table as encrypted arguments which is very difficult to maintain per multiple environment when databases is synchronized.

As workaround, everytime when my database is copied, I need to run the following code:

/**
 * Implements hook_install().
 */
function foo_migrate_install() {
  $connection6 = Database::getConnection('default', 'migrate');
  $connection7 = Database::getConnection('default', 'default');
  $info6       = $connection6->getConnectionOptions();

  // Updating migrate group source connection settings.
  $row = $connection7->select('migrate_group', 'mg')
    ->fields('mg')
    ->execute()
    ->fetchObject();

  $arguments = unserialize($row->arguments);
  $arguments = MigrationBase::decryptArguments($arguments);

  $arguments['source_database']['driver']    = $info6['driver'];
  $arguments['source_database']['database']  = $info6['database'];
  $arguments['source_database']['username']  = $info6['username'];
  $arguments['source_database']['password']  = $info6['password'];
  $arguments['source_database']['db_prefix'] = $info6['prefix']['default'];
  $arguments['source_database']['port']      = $info6['port'];
  $arguments['source_database']['host']      = $info6['host'];

  $connection7->update('migrate_group')
    ->fields(array(
      'arguments' => serialize(MigrationBase::encryptArguments($arguments)),
    ))
    ->execute();
}

So my credentials from $databases['migrate']['default'] are replacing these one which Migrate is using by default, which is migrate_group table.