Converting app from MySQL to PostgreSQL