This is an attempted workaround for postgres lastrowid problem.