I think this might have the same race condition as the Ruby code, unless there's a lock on the DB while this runs. Ie, what if two versions of this run concurrently, and both get the same `MAX(number)` because the other row hasn't been inserted yet?