Skip to content

Commit

Permalink
MDL-21840 backup - unify temp table support for backup & restore (mor…
Browse files Browse the repository at this point in the history
…e coming)
  • Loading branch information
stronk7 committed Jul 5, 2010
1 parent 210ee64 commit 4086bc7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/db/install.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20100705" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20100706" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
Expand Down Expand Up @@ -2648,8 +2648,10 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="backupid"/>
<FIELD NAME="backupid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="unique id of the backup" PREVIOUS="id" NEXT="itemname"/>
<FIELD NAME="itemname" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" COMMENT="name of the component this id belongs to (usually table names)" PREVIOUS="backupid" NEXT="itemid"/>
<FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="id of the component (usually table-&amp;gt;id values)" PREVIOUS="itemname" NEXT="parentitemid"/>
<FIELD NAME="parentitemid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="other id that can be useful to represent parent-child relations" PREVIOUS="itemid"/>
<FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="id of the component (usually table-&amp;gt;id values)" PREVIOUS="itemname" NEXT="newitemid"/>
<FIELD NAME="newitemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="new id of the component after restore" PREVIOUS="itemid" NEXT="parentitemid"/>
<FIELD NAME="parentitemid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="other id that can be useful to represent parent-child relations" PREVIOUS="newitemid" NEXT="info"/>
<FIELD NAME="info" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="to store information related with the item, base64(serialize())" PREVIOUS="parentitemid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="backupid_itemname_itemid_uk"/>
Expand Down
22 changes: 22 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4859,6 +4859,28 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2010070501);
}

if ($oldversion < 2010070502) {

/// Define field newitemid to be added to backup_ids_template
$table = new xmldb_table('backup_ids_template');
$field = new xmldb_field('newitemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'itemid');
/// Conditionally launch add field newitemid
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

/// Define field info to be added to backup_ids_template
$table = new xmldb_table('backup_ids_template');
$field = new xmldb_field('info', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'parentitemid');
/// Conditionally launch add field info
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

/// Main savepoint reached
upgrade_main_savepoint(true, 2010070502);
}


return true;
}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 2010070501; // YYYYMMDD = date of the last version bump
$version = 2010070502; // YYYYMMDD = date of the last version bump
// XX = daily increments

$release = '2.0 Preview 4 (Build: 20100705)'; // Human-friendly version name
Expand Down

0 comments on commit 4086bc7

Please sign in to comment.