$dbman->drop_field($table, $field);
}
- if ($dbman->table_exists($table)) {
- $dbman->drop_table($table);
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2012061800.01);
+ }
+
+ if ($oldversion < 2012062000.00) {
+ // Add field newcontextid to backup_files_template
+ $table = new xmldb_table('backup_files_template');
+ $field = new xmldb_field('newcontextid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'info');
+
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ upgrade_main_savepoint(true, 2012062000.00);
+ }
+
+ if ($oldversion < 2012062000.01) {
+ // Add field newitemid to backup_files_template
+ $table = new xmldb_table('backup_files_template');
+ $field = new xmldb_field('newitemid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'newcontextid');
+
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ upgrade_main_savepoint(true, 2012062000.01);
+ }
+
+
+ // Moodle v2.3.0 release upgrade line
+ // Put any upgrade step following this
+
+
+ if ($oldversion < 2012062500.02) {
+ // 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
+ // Conditionally launch drop field deleted from course_completion_crit_compl
+ if ($dbman->field_exists($table2, $field)) {
+ $dbman->drop_field($table2, $field);
}
- if ($dbman->table_exists($table)) {
- $dbman->drop_table($table);
+ // Drop unused table "course_completion_notify"
+ $table = new xmldb_table('course_completion_notify');
+
+ // Conditionally launch drop table course_completion_notify
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2012062500.02);
+ }
+
+ if ($oldversion < 2012062500.04) {
+ // Define table course_modules_avail_fields to be created
+ $table = new xmldb_table('course_modules_avail_fields');
+
+ // Adding fields to table course_modules_avail_fields
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('coursemoduleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('userfield', XMLDB_TYPE_CHAR, '50', null, null, null, null);
+ $table->add_field('customfieldid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
+ $table->add_field('operator', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('value', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+
+ // Adding keys to table course_modules_avail_fields
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('coursemoduleid', XMLDB_KEY_FOREIGN, array('coursemoduleid'), 'course_modules', array('id'));
+
+ // Conditionally launch create table for course_modules_avail_fields
+ if (!$dbman->table_exists($table)) {
+ $dbman->create_table($table);
}
- // Drop "timenotified" field from course_completions
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2012062500.04);
+ }
+
+ if ($oldversion < 2012062500.05) {
+ // Define table course_sections_avail_fields to be created
+ $table = new xmldb_table('course_sections_avail_fields');
+
+ // Adding fields to table course_sections_avail_fields
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('coursesectionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('userfield', XMLDB_TYPE_CHAR, '50', null, null, null, null);
+ $table->add_field('customfieldid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
+ $table->add_field('operator', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('value', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+
+ // Adding keys to table course_sections_avail_fields
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('coursesectionid', XMLDB_KEY_FOREIGN, array('coursesectionid'), 'course_sections', array('id'));
+
+ // Conditionally launch create table for course_sections_avail_fields
+ if (!$dbman->table_exists($table)) {
+ $dbman->create_table($table);
+ }
+
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2012062500.05);
+ }
+
++ if ($oldversion < 2012062500.06) {
++
++ // Drop "deleted" fields
+ $table = new xmldb_table('course_completions');
+ $field = new xmldb_field('timenotified');
++ $field = new xmldb_field('deleted');
++
++ // Conditionally launch drop field deleted from course_completions
++ if ($dbman->field_exists($table, $field)) {
++ $dbman->drop_field($table, $field);
++ }
+
++ $field = new xmldb_field('timenotified');
+ // Conditionally launch drop field timenotified from course_completions
+ if ($dbman->field_exists($table, $field)) {
+ $dbman->drop_field($table, $field);
+ }
+
+ // Main savepoint reached
- upgrade_main_savepoint(true, 2012052500.05);
++ upgrade_main_savepoint(true, 2012062500.06);
+ }
+
++ if ($oldversion < 2012062500.07) {
++ $table = new xmldb_table('course_completion_crit_compl');
++ $field = new xmldb_field('deleted');
++
++ // Conditionally launch drop field deleted from course_completion_crit_compl
++ if ($dbman->field_exists($table, $field)) {
++ $dbman->drop_field($table, $field);
++ }
++ // Main savepoint reached
++ upgrade_main_savepoint(true, 2012062500.07);
++ }
++
++ if ($oldversion < 2012062500.08) {
++
++ // Drop unused table "course_completion_notify"
++ $table = new xmldb_table('course_completion_notify');
++
++ // Conditionally launch drop table course_completion_notify
++ if ($dbman->table_exists($table)) {
++ $dbman->drop_table($table);
++ }
++
++ // Main savepoint reached
++ upgrade_main_savepoint(true, 2012062500.08);
++ }
++
return true;
}