3 // THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
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
16 if ($oldversion < 2002081000) {
17 if (! execute_sql("ALTER TABLE `journal_entries` ADD `mailed` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL")) {
21 if ($oldversion < 2002101200) {
22 execute_sql(" ALTER TABLE `journal_entries` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` ");
24 if ($oldversion < 2002122300) {
25 execute_sql("ALTER TABLE `journal_entries` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
28 if ($oldversion < 2003081701) {
29 table_column("journal", "assessed", "assessed", "integer", "10", "", "0");
30 table_column("journal_entries", "rating", "rating", "integer", "10", "", "0");
33 if ($oldversion < 2003081705) {
35 $defaultscale->courseid
= 0;
36 $defaultscale->userid
= 0;
37 $defaultscale->timemodified
= time();
38 $defaultscale->name
= get_string("journalrating2", "journal");
39 $defaultscale->scale
= get_string("journalrating1", "journal").",".
40 get_string("journalrating2", "journal").",".
41 get_string("journalrating3", "journal");
43 if ($defaultscale->id
= insert_record("scale", $defaultscale)) {
44 execute_sql("UPDATE {$CFG->prefix}journal SET assessed = '-$defaultscale->id'", false);
46 notify("An error occurred while inserting the default journal scale");
51 if ($oldversion < 2004011400) {
52 table_column("journal", "", "introformat", "integer", "2", "", "1", "not null", "intro");
55 if ($oldversion < 2004111200) {
56 execute_sql("ALTER TABLE {$CFG->prefix}journal DROP INDEX course;",false);
57 execute_sql("ALTER TABLE {$CFG->prefix}journal_entries DROP INDEX journal;",false);
58 execute_sql("ALTER TABLE {$CFG->prefix}journal_entries DROP INDEX userid;",false);
60 modify_database('','ALTER TABLE prefix_journal ADD INDEX course (course);');
61 modify_database('','ALTER TABLE prefix_journal_entries ADD INDEX journal (journal);');
62 modify_database('','ALTER TABLE prefix_journal_entries ADD INDEX userid (userid);');
65 if ($oldversion < 2005041100) { // replace wiki-like with markdown
66 include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
67 $wtm = new WikiToMarkdown();
69 $wtm->update( 'journal','intro','introformat' );
71 $sql = "select course from {$CFG->prefix}journal, {$CFG->prefix}journal_entries ";
72 $sql .= "where {$CFG->prefix}journal.id = {$CFG->prefix}journal_entries.journal ";
73 $sql .= "and {$CFG->prefix}journal_entries.id = ";
74 $wtm->update( 'journal_entries', 'text', 'format', $sql );
77 if ($oldversion < 2006042800) {
78 execute_sql("UPDATE {$CFG->prefix}journal SET name='' WHERE name IS NULL");
79 table_column('journal','name','name','varchar','255','','','not null');
81 execute_sql("UPDATE {$CFG->prefix}journal SET intro='' WHERE intro IS NULL");
82 table_column('journal','intro','intro','text','','','','not null');
85 if ($oldversion < 2006092100) {
86 table_column('journal_entries', 'comment', 'entrycomment', 'text', '', '', '', 'null');
89 ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.