diff --git a/lib/db/install.xml b/lib/db/install.xml index b125ffc638c..1dc2f221d12 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -2410,7 +2410,7 @@ - +
@@ -2423,5 +2423,48 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 3598fcf0e35..32509e89072 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3517,6 +3517,67 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); upgrade_main_savepoint($result, 2010041301); } + if ($result && $oldversion < 2010042100) { + + /// Define table backup_controllers to be created + $table = new xmldb_table('backup_controllers'); + + /// Adding fields to table backup_controllers + $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('type', XMLDB_TYPE_CHAR, '6', null, XMLDB_NOTNULL, null, null); + $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('format', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null); + $table->add_field('interactive', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('purpose', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('status', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('execution', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('executiontime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('checksum', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null); + $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('controller', XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null); + + /// Adding keys to table backup_controllers + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('backupid_uk', XMLDB_KEY_UNIQUE, array('backupid')); + $table->add_key('userid_fk', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); + + /// Adding indexes to table backup_controllers + $table->add_index('typeitem_ix', XMLDB_INDEX_NOTUNIQUE, array('type', 'itemid')); + + /// Conditionally launch create table for backup_controllers + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + /// Define table backup_ids_template to be created + $table = new xmldb_table('backup_ids_template'); + + /// Adding fields to table backup_ids_template + $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('itemname', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null); + $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('parentitemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null); + + /// Adding keys to table backup_ids_template + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('backupid_itemname_itemid_uk', XMLDB_KEY_UNIQUE, array('backupid', 'itemname', 'itemid')); + + /// Adding indexes to table backup_ids_template + $table->add_index('backupid_parentitemid_ix', XMLDB_INDEX_NOTUNIQUE, array('backupid', 'itemname', 'parentitemid')); + + /// Conditionally launch create table for backup_controllers + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2010042100); + } + return $result; } @@ -3524,4 +3585,4 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); // 1/ remove the automatic enabling of completion lib if debug enabled ( in 2008121701 block) // 2/ move 2009061300 block to the top of the file so that we may log upgrade queries // 3/ remove 2010033101 block -// 4/ remove 2010032400 block \ No newline at end of file +// 4/ remove 2010032400 block diff --git a/version.php b/version.php index 917e51f3e13..953258199bf 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 = 2010041301; // YYYYMMDD = date of the last version bump + $version = 2010042100; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20100421)'; // Human-friendly version name