Added bases for the migration memory boost feature - refs BT#4882

skala
Yannick Warnier 12 years ago
parent 2968ae32cd
commit 9319f3d497
  1. 7
      tests/migrate/config.dist.php
  2. 16
      tests/migrate/migration.class.php

@ -42,6 +42,13 @@ $db_pass = 'password';
$db_name = 'master';
//second DB
$db_name2 = 'master2';
/**
* Boost the migration by putting the relations tables in memory (as well as
* in the database). This might use huge amounts of memory when managing
* users bases of several hundred thousands, so the default is to disable it
*/
$boost = array('users'=>false, 'courses'=>false, 'sessions'=>false);
$config = array(

@ -56,6 +56,13 @@ class Migration {
* destination database field names) until ready to insert into Chamilo.
*/
public $data_list = array('users' => array(), 'courses' => array(), 'sessions' => array());
/**
* Whether to use the memory instead of the database (if the memory allows)
* This option has to be configured manually, and the default is to use
* the database, which is slower but much safer in terms of stability of
* the script (or let's say much more linear in terms of execution time)
*/
private $boost = array('users' => false, 'courses' => false, 'sessions' => false);
/**
* The constructor assigns all database connection details to the migration
@ -65,9 +72,10 @@ class Migration {
* @param string The original database's user
* @param string The original database's password
* @param string The original database's name
* @param array Array of parameters to define the memory-boost behaviour
* @return boolean False on error. Void on success.
*/
public function __construct($dbhost, $dbport, $dbuser, $dbpass, $dbname) {
public function __construct($dbhost, $dbport, $dbuser, $dbpass, $dbname, $boost=false) {
if (empty($dbhost) || empty($dbport) || empty($dbuser) || empty($dbpass) || empty($dbname)) {
$this->errors_stack[] = 'All origin database params must be given. Received ' . print_r(func_get_args(), 1);
return false;
@ -78,6 +86,10 @@ class Migration {
$this->odbuser = $dbuser;
$this->odbpass = $dbpass;
$this->odbname = $dbname;
// Set the boost level if set in config.php
if (!empty($boost) && is_array($boost)) {
$this->boost = $boost;
}
}
/**
@ -924,4 +936,4 @@ class Migration {
return $extra_fields;
}
}
}

Loading…
Cancel
Save