]> git.mjollnir.org Git - moodle.git/commitdiff
Moodle can now upgrade itself, just like the modules do
authormartin <martin>
Sat, 27 Jul 2002 13:09:08 +0000 (13:09 +0000)
committermartin <martin>
Sat, 27 Jul 2002 13:09:08 +0000 (13:09 +0000)
.htaccess
README
UPGRADES [deleted file]
UPGRADING [new file with mode: 0644]
admin/index.php
version.php [new file with mode: 0644]

index 66bd9c9db2f51a53eb37d302de85996ca2144cb9..40b0a30b9fc6e185133117caaa76f650ba5779e7 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -1,9 +1,5 @@
-WARNING: the CVS tree is currently a little unstable, 
-         as I'm doing some major work on the code.
+README     $Id$
+------
 
-         It may or may not work right now.
-
-         Martin - 18 May 2002
-------------------------------------------------------
 
 All the documention is in the "doc" subdirectory.  :-)
diff --git a/README b/README
index 66bd9c9db2f51a53eb37d302de85996ca2144cb9..40b0a30b9fc6e185133117caaa76f650ba5779e7 100644 (file)
--- a/README
+++ b/README
@@ -1,9 +1,5 @@
-WARNING: the CVS tree is currently a little unstable, 
-         as I'm doing some major work on the code.
+README     $Id$
+------
 
-         It may or may not work right now.
-
-         Martin - 18 May 2002
-------------------------------------------------------
 
 All the documention is in the "doc" subdirectory.  :-)
diff --git a/UPGRADES b/UPGRADES
deleted file mode 100644 (file)
index 9a5e3d5..0000000
--- a/UPGRADES
+++ /dev/null
@@ -1,20 +0,0 @@
-%Id%
-
-UPGRADING MOODLE
-----------------
-
-This file keeps track of changes to Moodle that may break 
-installations.  Whenever you upgrade the Moodle code from 
-an earlier version (by CVS, for example), check this file 
-to see if there is anything else you need to do to keep 
-your Moodle installation humming smoothly.
-
----------------------------------------------------------
-
-
-
-4-7-2002 Added 'teacher' type to forum->type
-
-You can use this SQL command to update your forum table:
-
-ALTER TABLE `forum` CHANGE `type` `type` ENUM('discussion','news','social','general','eachuser','teacher') DEFAULT 'general' NOT NULL
diff --git a/UPGRADING b/UPGRADING
new file mode 100644 (file)
index 0000000..669e523
--- /dev/null
+++ b/UPGRADING
@@ -0,0 +1,31 @@
+UPGRADING   $Id$
+---------
+
+Since the first main release of Moodle (2002080100)
+most upgrading is done automatically.  See the file
+version.php for all the details.
+
+When upgrading from any previous version of Moodle, 
+all you normally will need to do is this:
+
+1a) Update the source files using CVS
+
+    or
+
+1b) Make a backup of the current working installation 
+    files, then put the new files here.  Make sure you 
+    copy your old config.php back here (or make a new 
+    one by editing config-dist.php).
+
+2)  Login as the admin user and visit /admin using a 
+    web browser.
+
+If all goes well, your databases will be upgraded to 
+suit the new files, and you can go on using Moodle
+normally.
+
+If you have problems, let me know.
+
+Cheers,
+Martin
+
index 4f821e66b5dfb93e4398e9550bdb8987d8d13148..0dd554ea0205547164f20ed03fe541bfbe58b77f 100644 (file)
         die;
     }
 
+    // Check version of Moodle code on disk compared with database
+    // and upgrade if possible.
+
+    include_once("$CFG->dirroot/version.php");  # defines $version and upgrades
+
+    if ($dversion = get_field("config", "value", "name", "version")) { 
+        if ($version > $dversion) {  // upgrade
+            notify("Upgrading databases from version $dversion to $version...");
+            if (upgrade_moodle($dversion)) {
+                if (set_field("config", "value", "$version", "name", "version")) {
+                    notify("Databases were successfully upgraded");
+                    print_heading("<A HREF=\"index.php\">Continue</A>");
+                    die;
+                } else {
+                    notify("Upgrade failed!  (Could not update version in config table)");
+                }
+            } else {
+                notify("Upgrade failed!  See /version.php");
+            }
+        } else if ($version < $dversion) {
+            notify("WARNING!!!  The code you are using is OLDER than the version that made these databases!");
+        }
+       
+    } else {
+        $dversion->name  = "version";
+        $dversion->value = $version;
+        if (insert_record("config", $dversion)) {
+            notify("You are currently using Moodle version $version");
+            print_heading("<A HREF=\"index.php\">Continue</A>");
+            die;
+        } else {
+            error("A problem occurred inserting current version into databases");
+        }
+    }
+
     // Find and check all modules and load them up.
     $dir = opendir("$CFG->dirroot/mod");
     while ($mod = readdir($dir)) {
diff --git a/version.php b/version.php
new file mode 100644 (file)
index 0000000..7198bf0
--- /dev/null
@@ -0,0 +1,27 @@
+<?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.
+//
+// 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.
+
+$version = 2002072704;
+
+function upgrade_moodle($oldversion) {
+
+    return true;
+}
+
+?>