Skip to content

Commit

Permalink
MDL-65248 analytics: Replace upgrade script to apply for all moves
Browse files Browse the repository at this point in the history
While strictly we don't nedd to provide an upgrade path for master,
any dev/integration site already using some of the 3.7 new tagets
in models will break (class rename/move) if we don't perform the
update of all them.

This commit takes rid of the previous upgrade step, only performing
the update of a couple of targets and now supports all the (5) targets:

- course_dropout
- course_competencies
- course_completion
- course_gradetopass
- no_teaching
  • Loading branch information
stronk7 committed Apr 23, 2019
1 parent 3df9c60 commit 9c0edd1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
29 changes: 12 additions & 17 deletions lib/db/upgrade.php
Expand Up @@ -3184,28 +3184,23 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019041800.01);
}

if ($oldversion < 2019041900.00) {

$params = [
'target' => '\core\analytics\target\no_teaching',
if ($oldversion < 2019042000.00) {

// Let's update all (old core) targets to their new (core_course) locations.
$targets = [
'\core\analytics\target\course_competencies' => '\core_course\analytics\target\course_competencies',
'\core\analytics\target\course_completion' => '\core_course\analytics\target\course_completion',
'\core\analytics\target\course_dropout' => '\core_course\analytics\target\course_dropout',
'\core\analytics\target\course_gradetopass' => '\core_course\analytics\target\course_gradetopass',
'\core\analytics\target\no_teaching' => '\core_course\analytics\target\no_teaching',
];
$models = $DB->get_records('analytics_models', $params);
foreach ($models as $model) {
$model->target = '\core_course\analytics\target\no_teaching';
$DB->update_record('analytics_models', $model);
}

$params = [
'target' => '\core\analytics\target\course_dropout',
];
$models = $DB->get_records('analytics_models', $params);
foreach ($models as $model) {
$model->target = '\core_course\analytics\target\course_dropout';
$DB->update_record('analytics_models', $model);
foreach ($targets as $oldclass => $newclass) {
$DB->set_field('analytics_models', 'target', $newclass, ['target' => $oldclass]);
}

// Main savepoint reached.
upgrade_main_savepoint(true, 2019041900.00);
upgrade_main_savepoint(true, 2019042000.00);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2019041900.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2019042000.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit 9c0edd1

Please sign in to comment.