Changes to move to Postgres from sqllite