From a934bd23ffa820e7980377d461000e31a9961b47 Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Sun, 2 May 2010 17:35:51 +0000 Subject: [PATCH] MDL-21839 backup - added new backup logs table and cleaned some anymore in use --- .../util/factories/backup_factory.class.php | 2 +- lib/db/install.xml | 52 +++++++------------ lib/db/upgrade.php | 46 ++++++++++++++++ version.php | 2 +- 4 files changed, 68 insertions(+), 34 deletions(-) diff --git a/backup/util/factories/backup_factory.class.php b/backup/util/factories/backup_factory.class.php index 1fa9d4c917d..9655e8716bc 100644 --- a/backup/util/factories/backup_factory.class.php +++ b/backup/util/factories/backup_factory.class.php @@ -68,7 +68,7 @@ abstract class backup_factory { // and pointing to the backup_logs table $dllevel = isset($CFG->backup_database_logger_level) ? $CFG->backup_database_logger_level : backup::LOG_WARNING; $columns = array('backupid' => $backupid); - $enabledloggers[] = new database_logger($dllevel, 'timecreated', 'level', 'message', 'backup_logs', $columns); + $enabledloggers[] = new database_logger($dllevel, 'timecreated', 'loglevel', 'message', 'backup_logs', $columns); // Create extra file_logger, observing $CFG->backup_file_logger_extra and $CFG->backup_file_logger_extra_level // defaulting to $fllevel (normal file logger) diff --git a/lib/db/install.xml b/lib/db/install.xml index fea641e0dcb..ab13cb06699 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -2273,7 +2273,7 @@ - +
@@ -2284,35 +2284,7 @@
- - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- +
@@ -2591,7 +2563,7 @@
- +
@@ -2607,5 +2579,21 @@
+ + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 0845d707bfb..f83ffcfe41f 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3881,6 +3881,52 @@ AND EXISTS (SELECT 'x' upgrade_main_savepoint($result, 2010043001); } + if ($result && $oldversion < 2010050200) { + + /// Define table backup_logs to be created + $table = new xmldb_table('backup_logs'); + + /// Adding fields to table backup_logs + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('backupid', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null); + $table->add_field('loglevel', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('message', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); + $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + + /// Adding keys to table backup_logs + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('backupid', XMLDB_KEY_FOREIGN, array('backupid'), 'backup_controllers', array('backupid')); + + /// Adding indexes to table backup_logs + $table->add_index('backupid-id', XMLDB_INDEX_UNIQUE, array('backupid', 'id')); + + /// Conditionally launch create table for backup_logs + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + /// Drop some old backup tables, not used anymore + + /// Define table backup_files to be dropped + $table = new xmldb_table('backup_files'); + + /// Conditionally launch drop table for backup_files + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } + + /// Define table backup_ids to be dropped + $table = new xmldb_table('backup_ids'); + + /// Conditionally launch drop table for backup_ids + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2010050200); + } + return $result; } diff --git a/version.php b/version.php index 07c2a2fd5b5..e771089a706 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2010050100; // YYYYMMDD = date of the last version bump + $version = 2010050200; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20100502)'; // Human-friendly version name -- 2.43.0