MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / journal / db / postgres7.php
blob9064b093cddbb1c6091a15a022e531563cbeff79
1 <?php // $Id$
3 // THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
4 //
5 // IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
6 // LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
8 function journal_upgrade($oldversion) {
9 // This function does anything necessary to upgrade
10 // older versions to match current functionality
12 global $CFG;
14 $result = true;
16 if ($oldversion < 2003081705) {
17 $defaultscale = NULL;
18 $defaultscale->courseid = 0;
19 $defaultscale->userid = 0;
20 $defaultscale->timemodified = time();
21 $defaultscale->name = get_string("journalrating2", "journal");
22 $defaultscale->scale = get_string("journalrating1", "journal").",".
23 get_string("journalrating2", "journal").",".
24 get_string("journalrating3", "journal");
26 if ($defaultscale->id = insert_record("scale", $defaultscale)) {
27 execute_sql("UPDATE {$CFG->prefix}journal SET assessed = '-$defaultscale->id'", false);
28 } else {
29 notify("An error occurred while inserting the default journal scale");
30 $result = false;
34 if ($oldversion < 2004011400) {
35 table_column("journal", "", "introformat", "integer", "2", "", "1", "not null", "intro");
38 if ($oldversion < 2004111200) {
39 execute_sql("DROP INDEX {$CFG->prefix}journal_course_idx;",false);
40 execute_sql("DROP INDEX {$CFG->prefix}journal_entries_journal_idx;",false);
41 execute_sql("DROP INDEX {$CFG->prefix}journal_entries_userid_idx;",false);
43 modify_database('','CREATE INDEX prefix_journal_course_idx ON prefix_journal (course);');
44 modify_database('','CREATE INDEX prefix_journal_entries_journal_idx ON prefix_journal_entries (journal);');
45 modify_database('','CREATE INDEX prefix_journal_entries_userid_idx ON prefix_journal_entries (userid);');
48 if ($oldversion < 2005041100) { // replace wiki-like with markdown
49 include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
50 $wtm = new WikiToMarkdown();
51 // journal intro
52 $wtm->update( 'journal','intro','introformat' );
53 // journal entries
54 $sql = "select course from {$CFG->prefix}journal, {$CFG->prefix}journal_entries ";
55 $sql .= "where {$CFG->prefix}journal.id = {$CFG->prefix}journal_entries.journal ";
56 $sql .= "and {$CFG->prefix}journal_entries.id = ";
57 $wtm->update( 'journal_entries', 'text', 'format', $sql );
60 if ($oldversion < 2006092100) {
61 table_column('journal_entries', 'comment', 'entrycomment', 'text', '', '', '', 'null');
64 ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
66 return $result;