diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index d5e3e4c8596..862a0f71d2d 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3537,47 +3537,6 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); upgrade_main_savepoint($result, 2010042100); } - if ($result && $oldversion < 2010042200) { - //drop the previously created ratings table - $table = new xmldb_table('ratings'); - if ($dbman->table_exists($table)) { - $dbman->drop_table($table); - } - - //create the rating table (replaces module specific rating implementations) - $table = new xmldb_table('rating'); - if ($dbman->table_exists($table)) { - $dbman->drop_table($table); - } - - /// Adding fields to table rating - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); - - $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); - $table->add_field('scaleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('rating', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); - $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); - - $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); - $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); - - /// Adding keys to table rating - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id')); - $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); - - /// Adding indexes to table rating - $table->add_index('itemid', XMLDB_INDEX_NOTUNIQUE, array('itemid')); - - /// Create table for ratings - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - upgrade_main_savepoint($result, 2010042200); - } - if ($result && $oldversion < 2010042301) { $table = new xmldb_table('course_sections'); @@ -3644,6 +3603,47 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); upgrade_main_savepoint($result, 2010042303); } + if ($result && $oldversion < 2010042800) { + //drop the previously created ratings table + $table = new xmldb_table('ratings'); + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } + + //create the rating table (replaces module specific rating implementations) + $table = new xmldb_table('rating'); + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } + + /// Adding fields to table rating + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + + $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('scaleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); + $table->add_field('rating', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + + $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + + /// Adding keys to table rating + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id')); + $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); + + /// Adding indexes to table rating + $table->add_index('itemid', XMLDB_INDEX_NOTUNIQUE, array('itemid')); + + /// Create table for ratings + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + upgrade_main_savepoint($result, 2010042800); + } + return $result; } diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index e371e423be8..b4cf023c6bd 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -254,7 +254,7 @@ function xmldb_data_upgrade($oldversion) { upgrade_mod_savepoint($result, 2010031602, 'data'); } - if($result && $oldversion < 2010042300) { + if($result && $oldversion < 2010042800) { //migrate data ratings to the central rating table require_once($CFG->dirroot . '/lib/db/upgradelib.php'); @@ -273,9 +273,13 @@ WHERE m.name = :modname AND cxt.contextlevel = :contextlevel"; $DB->execute($sql, $params); - //todo andrew drop data_ratings + //now drop data_ratings + $table = new xmldb_table('data_ratings'); + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } - upgrade_mod_savepoint($result, 2010042300, 'data'); + upgrade_mod_savepoint($result, 2010042800, 'data'); } return $result; diff --git a/mod/data/version.php b/mod/data/version.php index 8132fa70c50..20581fff5e9 100644 --- a/mod/data/version.php +++ b/mod/data/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2010042300; -$module->requires = 2010042300; // Requires this Moodle version +$module->version = 2010042800; +$module->requires = 2010042800; // Requires this Moodle version $module->cron = 60; diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php index f87f9c61a72..cb984a6ce02 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -285,7 +285,7 @@ function xmldb_forum_upgrade($oldversion) { upgrade_mod_savepoint($result, 2009050400, 'forum'); } - if($result && $oldversion < 2010042200) { + if($result && $oldversion < 2010042800) { //migrate forumratings to the central rating table require_once($CFG->dirroot . '/lib/db/upgradelib.php'); @@ -305,9 +305,13 @@ WHERE m.name = :modname AND cxt.contextlevel = :contextlevel"; $DB->execute($sql, $params); - //todo andrew drop forum_ratings + //now drop forum_ratings + $table = new xmldb_table('forum_ratings'); + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } - upgrade_mod_savepoint($result, 2010042200, 'forum'); + upgrade_mod_savepoint($result, 2010042800, 'forum'); } return $result; diff --git a/mod/forum/version.php b/mod/forum/version.php index 91eee1297f7..449f1572845 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -24,8 +24,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$module->version = 2010042300; -$module->requires = 2010042300; // Requires this Moodle version +$module->version = 2010042800; +$module->requires = 2010042800; // Requires this Moodle version $module->cron = 60; diff --git a/mod/glossary/db/upgrade.php b/mod/glossary/db/upgrade.php index 32ecbb94cad..5d57fe2b480 100644 --- a/mod/glossary/db/upgrade.php +++ b/mod/glossary/db/upgrade.php @@ -260,7 +260,7 @@ function xmldb_glossary_upgrade($oldversion) { upgrade_mod_savepoint($result, 2009110800, 'glossary'); } - if($result && $oldversion < 2010042200) { + if($result && $oldversion < 2010042800) { //migrate glossary_ratings to the central rating table require_once($CFG->dirroot . '/lib/db/upgradelib.php'); @@ -280,9 +280,13 @@ WHERE m.name = :modname AND cxt.contextlevel = :contextlevel"; $DB->execute($sql, $params); - //todo andrew drop glossary_ratings + //now drop glossary_ratings + $table = new xmldb_table('glossary_ratings'); + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } - upgrade_mod_savepoint($result, 2010042200, 'glossary'); + upgrade_mod_savepoint($result, 2010042800, 'glossary'); } return $result; diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 1f57397bda7..14401b8ee26 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -5,8 +5,8 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2010042300; -$module->requires = 2010042300; // Requires this Moodle version +$module->version = 2010042800; +$module->requires = 2010042800; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) diff --git a/version.php b/version.php index 211b727c76a..b9a922c853b 100644 --- a/version.php +++ b/version.php @@ -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 = 2010042305; // YYYYMMDD = date of the last version bump + $version = 2010042800; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20100428)'; // Human-friendly version name