Index: upgrade.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/calculated/db/upgrade.php,v retrieving revision 1.6 diff -u -r1.6 upgrade.php --- upgrade.php 17 Sep 2008 05:24:29 -0000 1.6 +++ upgrade.php 27 Nov 2008 15:40:40 -0000 @@ -38,6 +38,25 @@ /// $result = result of database_manager methods /// upgrade_plugin_savepoint($result, YYYYMMDD00, 'qtype', 'calculated'); /// } + if ($result && $oldversion < XXXXXXXXXX ) { + + /// Define table question_calculated_options to be created + $table = new xmldb_table('question_calculated_options'); + + /// Adding fields to table question_calculated_options + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->add_field('question', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->add_field('synchronize', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null, null, '0'); + + /// Adding keys to table question_calculated_options + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('questionid', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id')); + + /// Conditionally launch create table for question_calculated_options + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + } return $result; }