refactoring - merged all the postgres commands into one script