mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
rating MDL-21657 updated rating upgrade process that drops old rating tables
This commit is contained in:
parent
a79db4058e
commit
c506e35496
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user