Skip to content

Commit

Permalink
MDL-21432 backup - make itemname bigger so it can store file componen…
Browse files Browse the repository at this point in the history
…t/area named
  • Loading branch information
stronk7 committed Jul 17, 2010
1 parent 9d49a14 commit d1c1105
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2687,7 +2687,7 @@
<FIELDS>
<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="itemname" TYPE="char" LENGTH="160" 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="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"/>
Expand Down Expand Up @@ -2733,4 +2733,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
31 changes: 31 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4790,6 +4790,37 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2010071300);
}

if ($oldversion < 2010071700) { // Make itemname bigger (160cc) to store component+filearea

$table = new xmldb_table('backup_ids_template');
// Define key backupid_itemname_itemid_uk (unique) to be dropped form backup_ids_template
$key = new xmldb_key('backupid_itemname_itemid_uk', XMLDB_KEY_UNIQUE, array('backupid', 'itemname', 'itemid'));
// Define index backupid_parentitemid_ix (not unique) to be dropped form backup_ids_template
$index = new xmldb_index('backupid_parentitemid_ix', XMLDB_INDEX_NOTUNIQUE, array('backupid', 'itemname', 'parentitemid'));
// Define field itemname to be 160cc
$field = new xmldb_field('itemname', XMLDB_TYPE_CHAR, '160', null, XMLDB_NOTNULL, null, null, 'backupid');

// Launch drop key backupid_itemname_itemid_uk
$dbman->drop_key($table, $key);
// Conditionally launch drop index backupid_parentitemid_ix
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}

// Changing precision of field itemname on table backup_ids_template to (160)
$dbman->change_field_precision($table, $field);

// Launch add key backupid_itemname_itemid_uk
$dbman->add_key($table, $key);
// Conditionally launch add index backupid_parentitemid_ix
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}

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


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 = 2010071600; // YYYYMMDD = date of the last version bump
$version = 2010071700; // YYYYMMDD = date of the last version bump
// XX = daily increments

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

0 comments on commit d1c1105

Please sign in to comment.