Update SQL again in messages_controller to work with Postgres