From 29ac9fc1f87fa257b5f6e8de15e539926de2ec15 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 4 Oct 2012 12:34:55 +0800 Subject: [PATCH 1/1] MDL-35768 create table course_format_options, increase length of course.format field --- lib/db/install.xml | 25 +++++++++++++++++++++---- lib/db/upgrade.php | 36 ++++++++++++++++++++++++++++++++++++ version.php | 2 +- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index b6f01ece6b3..f2261748dcf 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -77,7 +77,7 @@ - + @@ -420,7 +420,7 @@ - +
@@ -439,7 +439,24 @@
- +
+ + + + + + + + + + + + + + + +
+ diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index b75d16171a1..c467d2d3edf 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1311,5 +1311,41 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2012103003.00); } + if ($oldversion < 2012110200.00) { + + // Define table course_format_options to be created + $table = new xmldb_table('course_format_options'); + + // Adding fields to table course_format_options + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); + $table->add_field('format', XMLDB_TYPE_CHAR, '21', null, XMLDB_NOTNULL, null, null); + $table->add_field('sectionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'format'); + $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null); + $table->add_field('value', XMLDB_TYPE_TEXT, null, null, null, null, null); + + // Adding keys to table course_format_options + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id')); + + // Adding indexes to table course_format_options + $table->add_index('formatoption', XMLDB_INDEX_UNIQUE, array('courseid', 'format', 'sectionid', 'name')); + + // Conditionally launch create table for course_format_options + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + // Changing type of field format on table course to char with length 21 + $table = new xmldb_table('course'); + $field = new xmldb_field('format', XMLDB_TYPE_CHAR, '21', null, XMLDB_NOTNULL, null, 'topics', 'summaryformat'); + + // Launch change of type for field format + $dbman->change_field_type($table, $field); + + // Main savepoint reached + upgrade_main_savepoint(true, 2012110200.00); + } + return true; } diff --git a/version.php b/version.php index 4904073e6d7..1d983425d53 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2012110101.00; // YYYYMMDD = weekly release date of this DEV branch +$version = 2012110200.00; // YYYYMMDD = weekly release date of this DEV branch // RR = release increments - 00 in DEV branches // .XX = incremental changes -- 2.43.0