I have a simple need..
I need to create a handfull of additional fields in moodle core tables Having created and used XMLDB with success for a setof my own tables, it seems like that Moodle's XMLDB fails to create additional fields on some other tables.
is this something that should work, or should I just create a README.TXT with some SQL statements a user needs to execute to make this work?
Why can't you use one of Moodle's numerous plugin types?
if you know how to handle dynamite, it's not such a big deal. And the various Moodle plugins don't do what I want to do...
For me, it sounds quite a common operation to add additional fields into a moodle core table, I have done that lot's of times with other projects.
In my case I am adding additional property to a section (course_sections) for a special course format, adding a start date and end date for specific sections. In this case we don't do 'things' on a weekly or monthly base, but rather starts specific tasks on any date, and can end at any other other date. Sometimes it can take 3 weeks, other times 30 days...
Setting up a separate 1:1 table and go through the whole operation of handling my own retrieval/save and delete functions doesn't make sense.
If XMLDB cannot add additional fields to a existing table, then this is fine with me and I will supply a readme or install.txt file for appropriate instructions.
What you have to remember is that the install.xml file only affects what happens when Moodle (or a new plugin) is first installed. After that, changes to the DB structure are done my the upgrade.php file.
Don't even think about adding stuff to the main lib/db/upgrade.php. Instead use local/db/upgrade.php, and local/version.php to make the changes.
Don't make changes to lib/db/install.xml either. local/db/upgrade.php is run for a clean install, and there is no local/db/install.xml.
Note also that the way the local folder works is being changed in Moodle 2.0.
yes I understand the risk, and I am also making sure Moodle can insert records because the fields have proper database defaults.
I was hoping that XMLDB was 'smart' enough to read the database and the XMLDB schema, compare them and make proper updates, unfortunately this is not the case.
I will look into upgrade.php to add the additional fields.
thanks for your answer!
However, the XMLDB editor has the option to generate the PHP code that needs to go into update.php.
I want to add new column to course table and i use XMLDB editor to do that but Moodle 2.0, I can not use Edit function to add new column, I also config folder lib/db with permisson 777. If anybody has the same problem as me, Please share it to me. Thanks