Migrate to postgresql

Migrating to pgsql database and fixing some specs related to this change.