Until I started looking at the code it wasn’t apparent how a package should add tables to the database when being installed in Concrete5. As with much in C5 the answer is simple, but not easily found 🙁

In your package, in the top level directory, create the db.xml file in the same way that you would for a block and it will be automatically found and installed during an install or upgrade. Simples!

If you want to have the file elsewhere, then you can use this code in the install or upgrade function of your package controller

$dbfile = $this->getPackagePath().'/some/directory/db.xml';<br></br>
if (file_exists($dbfile)) {<br></br>

**NB** Tables that are installed this way are NOT removed when the package is uninstalled.