Migrate from MongoDB to Postgres (ready!)

I've rebased Undev@d51612ff7be776d7dfe899254768d4f059b72654 onto master. (c.f. #614)

I squashed @realmyst's commits for two reasons:
 1. many commits left the codebase in a transitional state
 2. to expedite rebasing