Permalink
Browse files

MDL-31291 assign: Fix diffs between installed & upgraded DB schema

  • Loading branch information...
stronk7 committed Sep 6, 2012
1 parent d59b488 commit 6f050c7deaf6a017c1e2d9eba7dbfe8a0913fb0d
Showing with 19 additions and 10 deletions.
  1. +19 −10 mod/assign/db/upgrade.php
View
@@ -124,20 +124,20 @@ function xmldb_assign_upgrade($oldversion) {
// Define field to be added to assign.
$table = new xmldb_table('assign');
- $field = new xmldb_field('teamsubmission', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED,
+ $field = new xmldb_field('teamsubmission', XMLDB_TYPE_INTEGER, '2', null,
XMLDB_NOTNULL, null, '0', 'cutoffdate');
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
- $field = new xmldb_field('requireallteammemberssubmit', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED,
+ $field = new xmldb_field('requireallteammemberssubmit', XMLDB_TYPE_INTEGER, '2', null,
XMLDB_NOTNULL, null, '0', 'teamsubmission');
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
- $field = new xmldb_field('teamsubmissiongroupingid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+ $field = new xmldb_field('teamsubmissiongroupingid', XMLDB_TYPE_INTEGER, '10', null,
XMLDB_NOTNULL, null, '0', 'requireallteammemberssubmit');
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
@@ -149,7 +149,7 @@ function xmldb_assign_upgrade($oldversion) {
$dbman->add_index($table, $index);
}
$table = new xmldb_table('assign_submission');
- $field = new xmldb_field('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'status');
+ $field = new xmldb_field('groupid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'status');
// Conditionally launch add field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
@@ -158,32 +158,41 @@ function xmldb_assign_upgrade($oldversion) {
}
if ($oldversion < 2012082400) {
- // Define field to be added to assign
+ // Define table assign_user_mapping to be created
$table = new xmldb_table('assign_user_mapping');
+ // Adding fields to table assign_user_mapping
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('assignment', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('assignment', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
+ $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
+ // Adding keys to table assign_user_mapping
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
- $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
$table->add_key('assignment', XMLDB_KEY_FOREIGN, array('assignment'), 'assign', array('id'));
+ $table->add_key('user', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
+ // Conditionally launch create table for assign_user_mapping
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
+ // Define field blindmarking to be added to assign
$table = new xmldb_table('assign');
- $field = new xmldb_field('blindmarking', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'teamsubmissiongroupingid');
+ $field = new xmldb_field('blindmarking', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'teamsubmissiongroupingid');
+
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
+ // Define field revealidentities to be added to assign
$table = new xmldb_table('assign');
- $field = new xmldb_field('revealidentities', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'blindmarking');
+ $field = new xmldb_field('revealidentities', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'blindmarking');
+
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
+
+ // assign savepoint reached
upgrade_mod_savepoint(true, 2012082400, 'assign');
}

0 comments on commit 6f050c7

Please sign in to comment.