Where is database install script??

Where is database install script??

by Random Blackburn -
Number of replies: 3
I'd like to take a look at the script that is used to create the database tables during the installation, but I can't find it anywhere.  Is any of this documented?  How am I supposed to make modifications if I can't find anything?
Average of ratings: -
In reply to Random Blackburn

Re: Where is database install script??

by Jan Dierckx -

The scripts to create db tables are located inside subdirectories named db. Because Moodle is modular, every module carries it's own databasetable install script. That's why there are more of them. If you are using Mysql, look for a file mysql.sql inside them. A file mysql.php is used to make upgrades to an existing moodle database setup.

  • Basic tables are setup in lib/db/mysql.sql

  • Tables for each block are setup in blocks/nameofblock/db/mysql.sql

  • Tables for each module are setup in mod/nameofmodule/db/mysql.sql

  • etc...

Mmmmm, I just reread your question. All of this may be way off topic because I could have misunderstood you. Your question: How am I supposed to make modifications... seems to pertain to modifications that a new user must do during installation. If that is the case (you are a new user and want to install Moodle for the first time) forget everything I just wrote. At that stage you don't need to manually create databasetables (as with some other PHP scripts) All of this is done by the Moodle install script. The only file you are supposed to make modifications to is config.php. Good luck!

In reply to Jan Dierckx

Re: Where is database install script??

by Penny Leach -
I interpreted that as they wanted to make modifications to moodle.. in which case, the developer docs are useful:

http://moodle.org/doc/

In particular, moodle has a code version number and a database version number. When there's a discrepency between these, it triggers an update.

So, if you (say) wanted to add a new field, you'd:

* bump the version number (these live in version.php and mod/modname/version.php and blocks/blockname/version.php) -- depending on what you want to change, you'd bump the particular version.php accordingly -- actually you'd want to do this LAST

* add the field to the pertinent (matching whichever version.php you want to update) mysql.sql or postgres7.sql file (which are meant to represent a FULL database schema)

* AND add in the upgrade to the matching mysql.php or postgres7.php in the form of
if ($oldversion < (whatever you changed version.php to be) ) {
// execute some sql to add the new field or whatever
}
which you should easily be able to copy from the existing structure.

* Then, visit admin/index.php and the upgrade will be triggered.


Hope that helps. Good luck!
In reply to Penny Leach

Re: Where is database install script??

by Random Blackburn -

Honestly, I wanted to find the script so I could make a version to install to SQL Server.  I'm trying to find a way to do a bulk transfer of data from BB to Moodle, and having both in SQL Server will help me out with that more.  Then, it'd be easier to do an export from Moodle's MSSQL database and import into the Moodle MySQL database.

I know 1.5.2 has a module to import courses from BB, but from what I understand, that has to be done on a course-by-course basis.  And really, I don't want all the courses, I just want the test pools, which can't be exported seperately.

Any advice would be appreciated.