When users will be migrating from Drupal 6.x to 7.x, there is no more $db_url variable, and we have the $databases array.

In most cases, users will not have $db_url as an array, in case they are using additional databases, or have master/slave databases. So, in this case, it should be straight forward to migrate their database settings. If they do have one of the advanced settings, then we should just give a message, and they are advanced enough to do it manually.

Here is a initial code for this ...

if (isset($db_url)) {
  $data = parse_url($db_url);

  $databases = array (
    'default' =>
    array (
      'default' =>
      array (
        'driver' => $data['scheme'],
        'database' => str_replace('/', '', $data['path']),
        'username' => $data['user'],
        'password' => $data['pass'],
        'host' => $data['host'],
        'port' => $data['port'],
      ),
    ),
  );

  print_r($databases);
}
else {
  // Give a message that they have to migrate manually
}

Comments

David_Rothstein’s picture

Just a note: This grew out of #303889: Impossible to update D6 -> D7, where there is now a patch that contains some proposed code similar to the above... (but it might get moved over here depending on how things go).

chx’s picture

Status: Needs work » Closed (duplicate)