Making it clear not to overwrite old files
[moodle.git] / lib / db / mysql.php
CommitLineData
31f0900c 1<?PHP //$Id$
2//
3// This file keeps track of upgrades to Moodle.
4//
5// Sometimes, changes between versions involve
6// alterations to database structures and other
7// major things that may break installations.
8//
9// The upgrade function in this file will attempt
10// to perform all the necessary actions to upgrade
11// your older installtion to the current version.
12//
13// If there's something it cannot do itself, it
14// will tell you what you need to do.
15//
16// Versions are defined by /version.php
17//
18// This file is tailored to MySQL
19
e7311a0a 20function main_upgrade($oldversion=0) {
31f0900c 21
22 if ($oldversion == 0) {
23 execute_sql("
24 CREATE TABLE `config` (
25 `id` int(10) unsigned NOT NULL auto_increment,
26 `name` varchar(255) NOT NULL default '',
27 `value` varchar(255) NOT NULL default '',
28 PRIMARY KEY (`id`),
29 UNIQUE KEY `name` (`name`)
30 ) COMMENT='Moodle configuration variables';");
31 notify("Created a new table 'config' to hold configuration data");
32 }
33 if ($oldversion < 2002073100) {
34 execute_sql(" DELETE FROM `modules` WHERE `name` = 'chat' ");
35 }
36 if ($oldversion < 2002080200) {
37 execute_sql(" ALTER TABLE `modules` DROP `fullname` ");
38 execute_sql(" ALTER TABLE `modules` DROP `search` ");
39 }
40 if ($oldversion < 2002080300) {
41 execute_sql(" ALTER TABLE `log_display` CHANGE `table` `mtable` VARCHAR( 20 ) NOT NULL ");
42 execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 3 ) DEFAULT '3' NOT NULL ");
43 }
44 if ($oldversion < 2002082100) {
45 execute_sql(" ALTER TABLE `course` CHANGE `guest` `guest` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL ");
46 }
47 if ($oldversion < 2002082101) {
48 execute_sql(" ALTER TABLE `user` ADD `maildisplay` TINYINT(2) UNSIGNED DEFAULT '2' NOT NULL AFTER `mailformat` ");
49 }
50 if ($oldversion < 2002090100) {
51 execute_sql(" ALTER TABLE `course_sections` CHANGE `summary` `summary` TEXT NOT NULL ");
52 }
53 if ($oldversion < 2002090701) {
54 execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 10 ) DEFAULT '3' NOT NULL ");
55 execute_sql(" ALTER TABLE `user_teachers` ADD `role` VARCHAR(40) NOT NULL AFTER `authority` ");
56 }
57 if ($oldversion < 2002090800) {
58 execute_sql(" ALTER TABLE `course` ADD `teachers` VARCHAR( 100 ) DEFAULT 'Teachers' NOT NULL AFTER `teacher` ");
59 execute_sql(" ALTER TABLE `course` ADD `students` VARCHAR( 100 ) DEFAULT 'Students' NOT NULL AFTER `student` ");
60 }
61 if ($oldversion < 2002091000) {
62 execute_sql(" ALTER TABLE `user` CHANGE `personality` `secret` VARCHAR( 15 ) DEFAULT NULL ");
63 }
64 if ($oldversion < 2002091400) {
65 execute_sql(" ALTER TABLE `user` ADD `lang` VARCHAR( 3 ) DEFAULT 'en' NOT NULL AFTER `country` ");
66 }
67 if ($oldversion < 2002091900) {
68 notify("Most Moodle configuration variables have been moved to the database and can now be edited via the admin page.");
69 notify("Although it is not vital that you do so, you might want to edit <U>config.php</U> and remove all the unused settings (except the database, URL and directory definitions). See <U>config-dist.php</U> for an example of how your new slim config.php should look.");
70 }
71 if ($oldversion < 2002092000) {
72 execute_sql(" ALTER TABLE `user` CHANGE `lang` `lang` VARCHAR(5) DEFAULT 'en' NOT NULL ");
73 }
74 if ($oldversion < 2002092100) {
75 execute_sql(" ALTER TABLE `user` ADD `deleted` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL AFTER `confirmed` ");
76 }
0095d5cd 77 if ($oldversion < 2002101001) {
78 execute_sql(" ALTER TABLE `user` ADD `htmleditor` TINYINT(1) UNSIGNED DEFAULT '1' NOT NULL AFTER `maildisplay` ");
79 }
2a439ba7 80 if ($oldversion < 2002101701) {
81 execute_sql(" ALTER TABLE `reading` RENAME `resource` "); // Small line with big consequences!
82 execute_sql(" DELETE FROM `log_display` WHERE module = 'reading'");
83 execute_sql(" INSERT INTO log_display VALUES ('resource', 'view', 'resource', 'name') ");
84 execute_sql(" UPDATE log SET module = 'resource' WHERE module = 'reading' ");
85 execute_sql(" UPDATE modules SET name = 'resource' WHERE name = 'reading' ");
86 }
31f0900c 87
88 return true;
89}
90
91?>