From 237957f12a3fd9203ddafce2d4050453118db78d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 8 May 2012 17:46:30 +0200 Subject: [PATCH] All databases (stat, user) are going to use the main DB see #3910 --- main/inc/lib/database.lib.php | 14 ++---------- main/install/update-db-1.8.8-1.9.0.inc.php | 25 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index 5eec8f7c56..f2942eb063 100644 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -43,17 +43,7 @@ class Database { */ public static function get_statistic_database() { global $_configuration; - return $_configuration['statistics_database']; - } - - /** - * Returns the name of the SCORM database. - * @todo use main_database - * @deprecated - */ - public static function get_scorm_database() { - global $_configuration; - return $_configuration['scorm_database']; + return $_configuration['main_database']; } /** @@ -62,7 +52,7 @@ class Database { */ public static function get_user_personal_database() { global $_configuration; - return $_configuration['user_personal_database']; + return $_configuration['main_database']; } /** diff --git a/main/install/update-db-1.8.8-1.9.0.inc.php b/main/install/update-db-1.8.8-1.9.0.inc.php index 0f982c14af..51eb5c5286 100755 --- a/main/install/update-db-1.8.8-1.9.0.inc.php +++ b/main/install/update-db-1.8.8-1.9.0.inc.php @@ -57,6 +57,7 @@ if (defined('SYSTEM_INSTALLATION')) { $only_test = false; $log = 0; if (defined('SYSTEM_INSTALLATION')) { + if ($singleDbForm) { $dbStatsForm = $dbNameForm; $dbScormForm = $dbNameForm; @@ -132,7 +133,7 @@ if (defined('SYSTEM_INSTALLATION')) { } } - //Moving Stats DB to the main database + //Moving Stats DB to the main DB $stats_table = array( "track_c_browsers", @@ -165,14 +166,30 @@ if (defined('SYSTEM_INSTALLATION')) { if ($dbNameForm != $dbStatsForm) { Database::select_db($dbStatsForm); - foreach($stats_table as $stat_table) { + foreach ($stats_table as $stat_table) { $sql = "ALTER TABLE $dbStatsForm.$stat_table RENAME $dbNameForm.$stat_table"; Database::query($sql); } Database::select_db($dbNameForm); } - - + + //Renaming user tables in the main DB + $user_tables = array( + 'personal_agenda', + 'personal_agenda_repeat', + 'personal_agenda_repeat_not', + 'user_course_category', + ); + + if ($dbNameForm != $dbUserForm) { + Database::select_db($dbUserForm); + foreach ($user_tables as $table) { + $sql = "ALTER TABLE $dbUserForm.$table RENAME $dbNameForm.$table"; + Database::query($sql); + } + Database::select_db($dbNameForm); + } + // Get the user queries list (u_q_list) $u_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'user');