Migrate from MongoDB to Postgresql

Ready for review

see documentation commit for details