Make exports consitent.

Previously, the exports were somewhat random with some files declaring
local variables then immediately exporting them, and others simply
doing the work needed in the export itself.
Merge pull request #2915 from rjackson/make-exports-consistent

Make exports more consistent.
Fix export of data during database migration

Closes #2927
-refactor exporter to export tables that exist in the
 database instead of keying off of schema.js
-move some shared database utility functions into their
 own module
Merge pull request #2928 from jaswilli/issue-2927-export

Fix export of data during database migration