Adding a database field to mdl_course_module with XMLDB and finding it back

Adding a database field to mdl_course_module with XMLDB and finding it back

by Rene Verheij -
Number of replies: 1

Hi, I'd like to add a field to the table mdl_course_module.

I'm looking at XMLDB..

I already have my own course_format module, so I created a /db folder in that course_format's folder and I can now access and edit it with the XMLDB editor.

What I'm not sure about is this ... When I edit the XML file of my own course_format module , do I then: add a new table from MySQL ... select the course_modules table ... and add a field to it? 

Cause I did that, added the field 'versionid', but I don't see that field coming back in the cm_info (course_module) object, yet ... Or should I not expect that?

Average of ratings: -
In reply to Rene Verheij

Re: Adding a database field to mdl_course_module with XMLDB and finding it back

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This sounds like a terrible idea - adding extra fields to core tables is a recipe for lots of problems when you run an update.

If you are really determined to do this and you want to populate the cm_info object, then you are going to have to go into the core code and alter the definition of the cm_info object and then clear the modinfo and sectioninfo fields in the mdl_course table (the rebuild_course_cache() function should do this for you, as well as clearing out any other related caching).

Still - I repeat, this is likely to be a bad idea.