PM-773 Unify DB no unifica cuando la bd tiene nombre distinto al ws.
PROBLEMA: Cuando la BD tiene un nombre distinto al WS el unify no funciona bien, creando una nueva bd con el nombre del ws. SOLUCION: Se recupera el nombre correcto de la bd y ya no se usa el nombre del ws para hacer el unify, ademas se agrego una validacion en la funcion resetDBInfoCallback() que solo aplica cuando se esta corriendo el unify, para q solo se cambie los prefijos de la configuracion del archivo db.php y nada mas.
This commit is contained in:
@@ -270,7 +270,7 @@ function run_unify_database($args)
|
|||||||
$link = mysql_connect( $dbHost, $dbUser, $dbPass );
|
$link = mysql_connect( $dbHost, $dbUser, $dbPass );
|
||||||
|
|
||||||
foreach ($metadata['databases'] as $db) {
|
foreach ($metadata['databases'] as $db) {
|
||||||
$dbName = 'wf_'.$workspace->name;
|
$dbName = $metadata['DB_NAME'];
|
||||||
CLI::logging( "+> Restoring {$db['name']} to $dbName database\n" );
|
CLI::logging( "+> Restoring {$db['name']} to $dbName database\n" );
|
||||||
|
|
||||||
$aParameters = array('dbHost'=>$dbHost,'dbUser'=>$dbUser,'dbPass'=>$dbPass);
|
$aParameters = array('dbHost'=>$dbHost,'dbUser'=>$dbUser,'dbPass'=>$dbPass);
|
||||||
@@ -290,7 +290,7 @@ function run_unify_database($args)
|
|||||||
CLI::logging( "Removing temporary files\n" );
|
CLI::logging( "Removing temporary files\n" );
|
||||||
G::rm_dir( $tempDirectory );
|
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" );
|
CLI::logging( CLI::info( "Done restoring databases" ) . "\n" );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,7 +250,16 @@ class workspaceTools
|
|||||||
/* Change the database name to the new workspace, following the standard
|
/* Change the database name to the new workspace, following the standard
|
||||||
* of prefix (either wf_, rp_, rb_) and the workspace name.
|
* 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 {
|
} else {
|
||||||
$dbName = $value;
|
$dbName = $value;
|
||||||
}
|
}
|
||||||
@@ -273,7 +282,7 @@ class workspaceTools
|
|||||||
* @param bool $resetDBNames if true, also reset all database names
|
* @param bool $resetDBNames if true, also reset all database names
|
||||||
* @return array contains the new database names as values
|
* @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) {
|
if (count(explode(":", $newHost)) < 2) {
|
||||||
$newHost .= ':3306';
|
$newHost .= ':3306';
|
||||||
@@ -282,6 +291,7 @@ class workspaceTools
|
|||||||
$this->resetDBNames = $resetDBNames;
|
$this->resetDBNames = $resetDBNames;
|
||||||
$this->resetDBDiff = array();
|
$this->resetDBDiff = array();
|
||||||
$this->onedb = $onedb;
|
$this->onedb = $onedb;
|
||||||
|
$this->unify = $unify;
|
||||||
|
|
||||||
if (!$this->workspaceExists()) {
|
if (!$this->workspaceExists()) {
|
||||||
throw new Exception("Could not find db.php in the workspace");
|
throw new Exception("Could not find db.php in the workspace");
|
||||||
|
|||||||
Reference in New Issue
Block a user