diff --git a/.htaccess b/.htaccess
index 66bd9c9db2f..40b0a30b9fc 100644
--- 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 66bd9c9db2f..40b0a30b9fc 100644
--- 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
index 9a5e3d5face..00000000000
--- 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
index 00000000000..669e523426f
--- /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
+
diff --git a/admin/index.php b/admin/index.php
index 4f821e66b5d..0dd554ea020 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -24,6 +24,41 @@
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("Continue");
+ 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("Continue");
+ 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
index 00000000000..7198bf0b440
--- /dev/null
+++ b/version.php
@@ -0,0 +1,27 @@
+