It seems lines 75-80 should be run only once per app, and are done per-migration only because they rely on the writer object. Can this be improved easily?