* Replace custom queries with dbDeleteOrphans().
Generalize dbDeleteOrphans() a bit more. Allow for multiple tables and custom key pairs.
* fix whitespace
* feature: save application metrics to db for alerting
However, alerting will not work because ResolveGlues() is broken.
Can add workaround after state_translations alerting is merged
Does not update all applications yet, not sure if that should be done here or in another PR.
Introduces two handy functions dbDeleteOrphans() and array_by_column(). Will replace those in other locations after this is merged or separate them out if this is not merged.
* remove accidental inclusions
* Add db schema
* refactor: use the Config class includes/discovery
* fix issue with $config variable not accessible in include-dir.inc.php
* improved whitespace
* Tidy up discovery_by_ip