updated to use postgresql instead of sqlite