[Vtigercrm-commits] [vtiger-commits] r4990 - in /vtigercrm/trunk/modules/Migration: Migration.php MigrationStep1.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri Apr 7 05:56:18 EDT 2006
Author: don
Date: Fri Apr 7 03:56:12 2006
New Revision: 4990
Log:
* Modified the script to get and apply the dump without failing specially for windows environment
Modified:
vtigercrm/trunk/modules/Migration/Migration.php
vtigercrm/trunk/modules/Migration/MigrationStep1.php
Modified: vtigercrm/trunk/modules/Migration/Migration.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/Migration.php (original)
+++ vtigercrm/trunk/modules/Migration/Migration.php Fri Apr 7 03:56:12 2006
@@ -61,22 +61,39 @@
$this->conn->println("New Database Parameters has been set.");
}
-
function takeDatabaseDump($host_name,$mysql_port,$mysql_username,$mysql_password,$dbname)
{
$this->conn->println("Inside the function taleDatabaseDump. Going to take the old database dump...");
$dump_filename = 'dump_'.$dbname.'.txt';
- exec("echo 'set FOREIGN_KEY_CHECKS = 0;' > ".$dump_filename);
if($mysql_password != '')
{
- exec("mysqldump -u".$mysql_username." -p".$mysql_password." -h ".$host_name." --port=".$mysql_port." ".$dbname." >> ".$dump_filename);
- }
- else
- {
- exec("mysqldump -u".$mysql_username." -h ".$host_name." --port=".$mysql_port." ".$dbname." >> ".$dump_filename);
- }
- exec("echo 'set FOREIGN_KEY_CHECKS = 1;' >> ".$dump_filename);
+ $password_str = " -p".$mysql_password;
+ }
+ else
+ {
+ $password_str = '';
+ }
+ if($_SESSION['windows_mysql_path'] != '')
+ {
+ $current_working_dir = getcwd();
+ $win_mysql_path = $_SESSION['windows_mysql_path'];
+
+ $dump_str = "mysqldump -u".$mysql_username.$password_str." -h ".$host_name." --port=".$mysql_port." ".$dbname." >> ".$dump_filename;
+
+ chdir ($win_mysql_path);
+
+ exec("echo 'set FOREIGN_KEY_CHECKS = 0;' > ".$dump_filename);
+ exec($dump_str);
+ exec("echo 'set FOREIGN_KEY_CHECKS = 1;' >> ".$dump_filename);
+
+ exec('cp "'.$win_mysql_path.'\\'.$dump_filename.'" "'.$current_working_dir.'\\'.$dump_filename).'"';
+ chdir ($current_working_dir);
+ }
+ else
+ {
+ exec("mysqldump -u".$mysql_username." -h ".$host_name.$password_str." --port=".$mysql_port." ".$dbname." >> ".$dump_filename);
+ }
echo '<br> Old Database Dump has been taken and the file is ==> '.$dump_filename;
@@ -107,11 +124,28 @@
{
if($mysql_password != '')
{
- exec("mysql --user=".$mysql_username." --password=".$mysql_password." -h ".$host_name." --force --port=".$mysql_port." ".$dbname." < ".$dumpfile);
- }
- else
- {
- exec("mysql --user=".$mysql_username." -h ".$host_name." --force --port=".$mysql_port." ".$dbname." < ".$dumpfile);
+ $password_str = " --password".$mysql_password;
+ }
+ else
+ {
+ $password_str = '';
+ }
+ if($_SESSION['windows_mysql_path'] != '')
+ {
+ $current_working_dir = getcwd();
+ $win_mysql_path = $_SESSION['windows_mysql_path'];
+
+ $dump_str = "mysql --user=".$mysql_username.$password_str." -h ".$host_name." --force --port=".$mysql_port." ".$dbname." < ".$dumpfile;
+
+ chdir ($win_mysql_path);
+
+ exec($dump_str);
+
+ chdir ($current_working_dir);
+ }
+ else
+ {
+ exec("mysql --user=".$mysql_username." -h ".$host_name." --force --port=".$mysql_port.$password_str." ".$dbname." < ".$dumpfile);
}
echo '<br> Old Database Dump has been applied to the Current Database.';
Modified: vtigercrm/trunk/modules/Migration/MigrationStep1.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/MigrationStep1.php (original)
+++ vtigercrm/trunk/modules/Migration/MigrationStep1.php Fri Apr 7 03:56:12 2006
@@ -26,6 +26,20 @@
{
$installed_mysql_path = $vtiger_home."/mysql/bin/mysqldump";
$getmysqlpath = false;
+}
+elseif(substr($_ENV["OS"],0,3) == "Win")
+{
+ if(is_file($vtiger_home.'\mysql\bin\mysql.exe'))
+ {
+ $installed_mysql_path = $vtiger_home.'\mysql\bin\mysqldump.exe';
+ @session_unregister('windows_mysql_path');
+ $_SESSION['windows_mysql_path'] = $vtiger_home.'\mysql\bin';
+ $getmysqlpath = false;
+ }
+ else
+ {
+ $getmysqlpath = true;
+ }
}
else
{
More information about the vtigercrm-commits
mailing list