function drush_upgrade_fix_db_url

3.x upgrade.drush.inc drush_upgrade_fix_db_url($target_alias, $settings_destination)
4.x upgrade.drush.inc drush_upgrade_fix_db_url(&$target_alias, $settings_destination)
1 call to drush_upgrade_fix_db_url()
drush_upgrade_site_upgrade in commands/core/upgrade.drush.inc
A drush command callback.

File

commands/core/upgrade.drush.inc, line 146

Code

function drush_upgrade_fix_db_url($target_alias, $settings_destination) {
  $old_url = $GLOBALS['db_url'];
  if (is_array($old_url)) {
    $old_url = $old_url['default'];
  }
  $target_alias_databases = sitealias_get_databases_from_record($target_alias);
  $new_url = substr($old_url, 0, strrpos(trim($old_url), '/')) . '/' . $target_alias_databases['default']['default']['database'];

  $append = "\n# Added by drush site-upgrade.";
  if (drush_drupal_major_version() <= 6) {
    $append .= "\n" . '$db_url = \'' . $new_url . '\';';
  }
  else {
    $databases = $GLOBALS['databases'];
    $databases['default']['default']['database'] = $target_alias_databases['default']['default']['database'];
    $append .= "\n" . '$databases = ' . var_export($databases, TRUE) . ';';
  }
  drush_op('file_put_contents', $settings_destination, $append, FILE_APPEND);
}