XMLDB Modifying the installation/upgrade process
Once the XMLDB is ready, both the installation and the upgrade process will change notably and the schema used before Moodle 1.7 will be deprecated soon. Let's see some details about the changes.
Prior to Moodle 1.7, all the initial DB creation was performed reading and executing the information present in some "*.sql" files present under every "db" directory (lib/db, mod/xxx/db, block/xxx/db...). For each directory, at least two .sql files were present, "mysql.sql" and "postgres7.sql", each one ready to be used depending of the DB selected (MySQL or PostgreSQL).
Starting with Moodle 1.7, all those *.sql files become completely replaced for one new file, "install.xml" which contains the necessary info to create all the DB structures for any DB supported by Moodle 1.7 (MySQL, PostgrSQL, SQL*Server and Oracle).
These new, abstract and common install.xml files completely replace the old "*.sql" so they don't need to be maintained anymore (they'll be out from Moodle core code soon). Also, all the 3rd part contributions using db structures should migrate to the new "install.xml" files asap (it should be pretty easy to do so using the integrated XMLDEditor.
Anyway, in order to maintain compatibility with all those 3rd part code contributions, the old .sql files for those modules, blocks... will continue being usable (only under MySQL and PostgreSQL!) until their new install.xml files will be created by developers.
Summarising: For each "db" dir inside Moodle, if the "install.xml" file is found, it will be used to create all the DB structures, else, the old ".sql" file will be used.
Similarly to the Installation notes above, prior to Moodle 1.7, every "db" dir contained some database dependent files"*.php" files (mysql.php, postgres7.php) in order to perform all the DB upgrade operations needed for each module.
With Moodle 1.7, all these files won't be edited anymore and the new, common, "upgrade.php" will be executed for all the upgrades within Moodle. But note that the behaviour is slightly different from the explained for installations.
The new "upgrade.php" don't replace the old ".php" files at all. It simply is executed after the old ones. Obviously this has some implications:
- All the upgrade from older versions up to Moodle 1.7 has been developed using the old, db dependent files (obviously this only will affect to MySQL and PostgreSQL DBs, because no upgrade is present both for MSSQL and Oracle before 1.7).
- Every time one new "upgrade.php" file has been created inside any "db" directory, one clear note should be written in the old ".php" files, in order to avoid further actions on them. Only the new file must be used since this moment.
This approach also benefits all the 3rd part contributions because their upgrade code will be executed without problem under existing MySQL and PostgrSQL installations. Anyway, they should start to work with the new "upgrade.php" files asap to be able to run under new databases.
It's highly recommended to use and experiment with the XMLDEditor because it includes one PHP generator that will help in the process of learning more about how to handle all the new DDL functions properly.
Summarising: For each "db" dir inside Moodle, if the "upgrade.php" file is found, it will executed after ".php" ones. Once the new "upgrade.php" is created, the old ones must remain unmodified forever.