Updated migration scripts to share index array - refs BT#4890

skala
Yannick Warnier 13 years ago
parent 0d52a5ff2c
commit f488a09da9
  1. 3
      tests/migrate/migrate.php
  2. 32
      tests/migrate/migration.class.php
  3. 854
      tests/migrate/migration.custom.class.php
  4. 9
      tests/migrate/migration.mssql.class.php

@ -27,6 +27,8 @@ if (empty($servers)) {
die("This script requires a servers array with the connection settings and the file to parse\n");
}
$data_list = array('users'=>array(),'courses'=>array(),'sessions'=>array());
$start = time();
echo "\n-- Starting at ".date('h:i:s')." local server time\n";
if (!empty($servers)) {
@ -34,6 +36,7 @@ if (!empty($servers)) {
if ($server_info['active']) {
echo "\n---- Start loading server----- \n";
echo $server_info['name']."\n\n";
error_log('Treating server '.$server_info['name']);
//echo "---- ----------------------- \n";
$config_info = $server_info['connection'];

@ -50,20 +50,6 @@ class Migration {
*/
public $odbrows = null;
/**
* Temporary holder for the list of users, courses and sessions and their
* data. Store values here (preferably using the same indexes as the
* destination database field names) until ready to insert into Chamilo.
*/
public $data_list = array(
'boost_users' => false,
'users' => array(),
'boost_courses' => false,
'courses' => array(),
'boost_sessions' => false,
'sessions' => array(),
);
public $web_service_connection_info = array();
/**
@ -90,9 +76,10 @@ class Migration {
// Set the boost level if set in config.php
if (!empty($boost) && is_array($boost)) {
global $data_list;
foreach ($boost as $item => $val) {
if ($val == true) {
$this->data_list[$item] = true;
$data_list[$item] = true;
}
}
}
@ -1014,6 +1001,7 @@ class Migration {
$extra_field_value_obj = new ExtraFieldValue($table['dest_table']);
}
$extra_fields_to_insert = array();
global $data_list;
foreach ($table['fields_match'] as $id_field => $details) {
//if ($table['dest_table'] == 'session') {error_log('Processing field '.$details['orig']);}
@ -1033,7 +1021,7 @@ class Migration {
} else {
// if an alteration function is defined, run it on the field
//error_log(__FILE__.' '.__LINE__.' Preparing to treat field with '.$details['func']);
$dest_data = MigrationCustom::$details['func']($row[$details['orig']], $this->data_list, $row);
$dest_data = MigrationCustom::$details['func']($row[$details['orig']], $data_list, $row);
}
if (isset($dest_row[$details['dest']])) {
@ -1098,7 +1086,7 @@ class Migration {
//error_log('Calling '.$table['dest_func'].' on data recovered: '.print_r($dest_row, 1));
$dest_row['return_item_if_already_exists'] = true;
$item_result = call_user_func_array($table['dest_func'], array($dest_row, $this->data_list));
$item_result = call_user_func_array($table['dest_func'], array($dest_row, $data_list));
/* if (isset($table['show_in_error_log']) && $table['show_in_error_log'] == false) {
@ -1107,12 +1095,12 @@ class Migration {
}
*/
//error_log('Result of calling ' . $table['dest_func'] . ': ' . print_r($item_result, 1));
//After the function was executed fill the $this->data_list array
//After the function was executed fill the $data_list array
switch ($table['dest_table']) {
case 'course':
//Saving courses in array
if ($item_result) {
//$this->data_list['courses'][$dest_row['uidIdCurso']] = $item_result;
//$data_list['courses'][$dest_row['uidIdCurso']] = $item_result;
} else {
error_log('Course Not FOUND');
error_log(print_r($item_result, 1));
@ -1125,11 +1113,11 @@ class Migration {
$handler_id = $item_result['user_id'];
//error_log($dest_row['email'].' '.$dest_row['uidIdPersona']);
if (isset($dest_row['uidIdAlumno'])) {
//$this->data_list['users_alumno'][$dest_row['uidIdAlumno']]['extra'] = $item_result;
//$data_list['users_alumno'][$dest_row['uidIdAlumno']]['extra'] = $item_result;
}
if (isset($dest_row['uidIdEmpleado'])) {
//print_r($dest_row['uidIdEmpleado']);exit;
//$this->data_list['users_empleado'][$dest_row['uidIdEmpleado']]['extra'] = $item_result;
//$data_list['users_empleado'][$dest_row['uidIdEmpleado']]['extra'] = $item_result;
}
} else {
global $api_failureList;
@ -1138,7 +1126,7 @@ class Migration {
}
break;
case 'session':
//$this->data_list['sessions'][$dest_row['uidIdPrograma']] = $item_result;
//$data_list['sessions'][$dest_row['uidIdPrograma']] = $item_result;
$handler_id = $item_result; //session_id
break;
}

File diff suppressed because it is too large Load Diff

@ -35,10 +35,13 @@ class MigrationMSSQL extends Migration {
$top = null;
// $top = " TOP 100000 ";
if (in_array($table, array('Empleado', 'Alumno'))) {
// $top = " TOP 2000 ";
//$top = " TOP 2000 ";
}
if (in_array($table, array('ProgramaAcademico', 'Matricula'))) {
if ($table == 'ProgramaAcademico') {
//$top = ' TOP 1000 ';
}
if ($table == 'Matricula') {
//$top = " TOP 1000 ";
}

Loading…
Cancel
Save