diff --git a/workflow/engine/bin/tasks/cliUpgrade.php b/workflow/engine/bin/tasks/cliUpgrade.php index d76dd1b38..394b06f2d 100755 --- a/workflow/engine/bin/tasks/cliUpgrade.php +++ b/workflow/engine/bin/tasks/cliUpgrade.php @@ -270,7 +270,7 @@ function run_unify_database($args) $link = mysql_connect( $dbHost, $dbUser, $dbPass ); foreach ($metadata['databases'] as $db) { - $dbName = 'wf_'.$workspace->name; + $dbName = $metadata['DB_NAME']; CLI::logging( "+> Restoring {$db['name']} to $dbName database\n" ); $aParameters = array('dbHost'=>$dbHost,'dbUser'=>$dbUser,'dbPass'=>$dbPass); @@ -290,7 +290,7 @@ function run_unify_database($args) CLI::logging( "Removing temporary files\n" ); G::rm_dir( $tempDirectory ); - $newDBNames = $workspace->resetDBInfo( $dbHost, true, true ); + $newDBNames = $workspace->resetDBInfo( $dbHost, true, true, true ); CLI::logging( CLI::info( "Done restoring databases" ) . "\n" ); } diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index ae92533c0..bc1a9ce75 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -250,7 +250,16 @@ class workspaceTools /* Change the database name to the new workspace, following the standard * of prefix (either wf_, rp_, rb_) and the workspace name. */ - $dbName = $dbPrefix[$key] . $this->name; + if($this->unify){ + $nameDb = explode("_", $value); + if(!isset($nameDb[1])){ + $dbName = $value; + } else { + $dbName = $dbPrefix[$key] . $nameDb[1]; + } + }else { + $dbName = $dbPrefix[$key] . $this->name; + } } else { $dbName = $value; } @@ -273,7 +282,7 @@ class workspaceTools * @param bool $resetDBNames if true, also reset all database names * @return array contains the new database names as values */ - public function resetDBInfo($newHost, $resetDBNames = true, $onedb = false) + public function resetDBInfo($newHost, $resetDBNames = true, $onedb = false, $unify = false) { if (count(explode(":", $newHost)) < 2) { $newHost .= ':3306'; @@ -282,6 +291,7 @@ class workspaceTools $this->resetDBNames = $resetDBNames; $this->resetDBDiff = array(); $this->onedb = $onedb; + $this->unify = $unify; if (!$this->workspaceExists()) { throw new Exception("Could not find db.php in the workspace");