]> git.mjollnir.org Git - moodle.git/commitdiff
Moved upgrade_moodle functions out to database-specific files, because
authormoodler <moodler>
Sat, 5 Oct 2002 17:09:31 +0000 (17:09 +0000)
committermoodler <moodler>
Sat, 5 Oct 2002 17:09:31 +0000 (17:09 +0000)
the SQL is not compatible (nor is it possible to make it so).

admin/index.php
lib/db/mysql.php [new file with mode: 0644]
lib/db/postgres7.php [new file with mode: 0644]
version.php

index 30447a6702617e0917fa7258c98e63e966f5ce13..7f65db4aefe13938bbd4de7a5e712f264bfe9029 100644 (file)
@@ -56,7 +56,8 @@
 /// Check version of Moodle code on disk compared with database
 /// and upgrade if possible.
 
-    include_once("$CFG->dirroot/version.php");  # defines $version and upgrades
+    include_once("$CFG->dirroot/version.php");              # defines $version 
+    include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php");  # defines upgrades
 
     if ($CFG->version) { 
         if ($version > $CFG->version) {  // upgrade
diff --git a/lib/db/mysql.php b/lib/db/mysql.php
new file mode 100644 (file)
index 0000000..79987e6
--- /dev/null
@@ -0,0 +1,81 @@
+<?PHP  //$Id$
+//
+// This file keeps track of upgrades to Moodle.
+// 
+// Sometimes, changes between versions involve 
+// alterations to database structures and other 
+// major things that may break installations.  
+//
+// The upgrade function in this file will attempt
+// to perform all the necessary actions to upgrade
+// your older installtion to the current version.
+//
+// If there's something it cannot do itself, it 
+// will tell you what you need to do.
+//
+// Versions are defined by /version.php
+//
+// This file is tailored to MySQL
+
+function upgrade_moodle($oldversion=0) {
+
+    if ($oldversion == 0) {
+        execute_sql("
+          CREATE TABLE `config` (
+            `id` int(10) unsigned NOT NULL auto_increment,
+            `name` varchar(255) NOT NULL default '',
+            `value` varchar(255) NOT NULL default '',
+            PRIMARY KEY  (`id`),
+            UNIQUE KEY `name` (`name`)
+          ) COMMENT='Moodle configuration variables';");
+        notify("Created a new table 'config' to hold configuration data");
+    }
+    if ($oldversion < 2002073100) {
+        execute_sql(" DELETE FROM `modules` WHERE `name` = 'chat' ");
+    }
+    if ($oldversion < 2002080200) {
+        execute_sql(" ALTER TABLE `modules` DROP `fullname`  ");
+        execute_sql(" ALTER TABLE `modules` DROP `search`  ");
+    }
+    if ($oldversion < 2002080300) {
+        execute_sql(" ALTER TABLE `log_display` CHANGE `table` `mtable` VARCHAR( 20 ) NOT NULL ");
+        execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 3 ) DEFAULT '3' NOT NULL ");
+    }
+    if ($oldversion < 2002082100) {
+        execute_sql(" ALTER TABLE `course` CHANGE `guest` `guest` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL ");
+    }
+    if ($oldversion < 2002082101) {
+        execute_sql(" ALTER TABLE `user` ADD `maildisplay` TINYINT(2) UNSIGNED DEFAULT '2' NOT NULL AFTER `mailformat` ");
+    }
+    if ($oldversion < 2002090100) {
+        execute_sql(" ALTER TABLE `course_sections` CHANGE `summary` `summary` TEXT NOT NULL ");
+    }
+    if ($oldversion < 2002090701) {
+        execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 10 ) DEFAULT '3' NOT NULL ");
+        execute_sql(" ALTER TABLE `user_teachers` ADD `role` VARCHAR(40) NOT NULL AFTER `authority` ");
+    }
+    if ($oldversion < 2002090800) {
+        execute_sql(" ALTER TABLE `course` ADD `teachers` VARCHAR( 100 ) DEFAULT 'Teachers' NOT NULL AFTER `teacher` ");
+        execute_sql(" ALTER TABLE `course` ADD `students` VARCHAR( 100 ) DEFAULT 'Students' NOT NULL AFTER `student` ");
+    }
+    if ($oldversion < 2002091000) {
+        execute_sql(" ALTER TABLE `user` CHANGE `personality` `secret` VARCHAR( 15 ) DEFAULT NULL  ");
+    }
+    if ($oldversion < 2002091400) {
+        execute_sql(" ALTER TABLE `user` ADD `lang` VARCHAR( 3 ) DEFAULT 'en' NOT NULL AFTER `country`  ");
+    }
+    if ($oldversion < 2002091900) {
+        notify("Most Moodle configuration variables have been moved to the database and can now be edited via the admin page.");
+        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.");
+    }
+    if ($oldversion < 2002092000) {
+        execute_sql(" ALTER TABLE `user` CHANGE `lang` `lang` VARCHAR(5) DEFAULT 'en' NOT NULL  ");
+    }
+    if ($oldversion < 2002092100) {
+        execute_sql(" ALTER TABLE `user` ADD `deleted` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL AFTER `confirmed` ");
+    }
+
+    return true;
+}
+
+?>
diff --git a/lib/db/postgres7.php b/lib/db/postgres7.php
new file mode 100644 (file)
index 0000000..8cb8b6e
--- /dev/null
@@ -0,0 +1,25 @@
+<?PHP  //$Id$
+//
+// This file keeps track of upgrades to Moodle.
+// 
+// Sometimes, changes between versions involve 
+// alterations to database structures and other 
+// major things that may break installations.  
+//
+// The upgrade function in this file will attempt
+// to perform all the necessary actions to upgrade
+// your older installtion to the current version.
+//
+// If there's something it cannot do itself, it 
+// will tell you what you need to do.
+//
+// Versions are defined by /version.php
+//
+// This file is tailored to PostgreSQL 7
+
+function upgrade_moodle($oldversion=0) {
+
+    return true;
+}
+
+?>
index d04d31a44c537f3b5e5fc49721c5a8ec73a174a9..de5f4ea266a39db48a545602c32d81e4a1a9c7de 100644 (file)
@@ -1,87 +1,11 @@
 <?PHP  //$Id$
-// This file keeps track of upgrades to Moodle.
-// 
-// Sometimes, changes between versions involve 
-// alterations to database structures and other 
-// major things that may break installations.  
-//
-// This file specifies the current version of 
-// Moodle installed, which can be compared against
-// a previous version (see the "config" table).
-//
-// To do this, visit the "admin" page or the site
-// home page while logged in as an admin.
-//
-// The upgrade function in this file will attempt
-// to perform all the necessary actions to upgrade
-// your older databases to the current version.
-// If there's something it cannot do itself, it 
-// will tell you what you need to do.
+// This file defines the current version of the
+// Moodle code that is being used.  This can be
+// compared against the values stored in the 
+// database to determine whether upgrades should
+// be performed (see lib/db/*.php)
 
-$version = 2002100200;   // The current version is a date (YYYYMMDDXX) where 
-                         //    XX is a number that increments during the day
+$version = 2002100200;   // The current version is a date (YYYYMMDDXX)
 
-$release = "1.0.6 dev";      // For humans only, not used for the upgrade process
+$release = "1.0.6 dev";  // User-friendly version number
 
-function upgrade_moodle($oldversion=0) {
-
-    if ($oldversion == 0) {
-        execute_sql("
-          CREATE TABLE `config` (
-            `id` int(10) unsigned NOT NULL auto_increment,
-            `name` varchar(255) NOT NULL default '',
-            `value` varchar(255) NOT NULL default '',
-            PRIMARY KEY  (`id`),
-            UNIQUE KEY `name` (`name`)
-          ) COMMENT='Moodle configuration variables';");
-        notify("Created a new table 'config' to hold configuration data");
-    }
-    if ($oldversion < 2002073100) {
-        execute_sql(" DELETE FROM `modules` WHERE `name` = 'chat' ");
-    }
-    if ($oldversion < 2002080200) {
-        execute_sql(" ALTER TABLE `modules` DROP `fullname`  ");
-        execute_sql(" ALTER TABLE `modules` DROP `search`  ");
-    }
-    if ($oldversion < 2002080300) {
-        execute_sql(" ALTER TABLE `log_display` CHANGE `table` `mtable` VARCHAR( 20 ) NOT NULL ");
-        execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 3 ) DEFAULT '3' NOT NULL ");
-    }
-    if ($oldversion < 2002082100) {
-        execute_sql(" ALTER TABLE `course` CHANGE `guest` `guest` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL ");
-    }
-    if ($oldversion < 2002082101) {
-        execute_sql(" ALTER TABLE `user` ADD `maildisplay` TINYINT(2) UNSIGNED DEFAULT '2' NOT NULL AFTER `mailformat` ");
-    }
-    if ($oldversion < 2002090100) {
-        execute_sql(" ALTER TABLE `course_sections` CHANGE `summary` `summary` TEXT NOT NULL ");
-    }
-    if ($oldversion < 2002090701) {
-        execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 10 ) DEFAULT '3' NOT NULL ");
-        execute_sql(" ALTER TABLE `user_teachers` ADD `role` VARCHAR(40) NOT NULL AFTER `authority` ");
-    }
-    if ($oldversion < 2002090800) {
-        execute_sql(" ALTER TABLE `course` ADD `teachers` VARCHAR( 100 ) DEFAULT 'Teachers' NOT NULL AFTER `teacher` ");
-        execute_sql(" ALTER TABLE `course` ADD `students` VARCHAR( 100 ) DEFAULT 'Students' NOT NULL AFTER `student` ");
-    }
-    if ($oldversion < 2002091000) {
-        execute_sql(" ALTER TABLE `user` CHANGE `personality` `secret` VARCHAR( 15 ) DEFAULT NULL  ");
-    }
-    if ($oldversion < 2002091400) {
-        execute_sql(" ALTER TABLE `user` ADD `lang` VARCHAR( 3 ) DEFAULT 'en' NOT NULL AFTER `country`  ");
-    }
-    if ($oldversion < 2002091900) {
-        notify("Most Moodle configuration variables have been moved to the database and can now be edited via the admin page.");
-        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.");
-    }
-    if ($oldversion < 2002092000) {
-        execute_sql(" ALTER TABLE `user` CHANGE `lang` `lang` VARCHAR(5) DEFAULT 'en' NOT NULL  ");
-    }
-    if ($oldversion < 2002092100) {
-        execute_sql(" ALTER TABLE `user` ADD `deleted` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL AFTER `confirmed` ");
-    }
-
-    return true;
-}
-
-?>