Couchdb to PostgreSQL php dump script