If you commit the transaction inside the onupgradeneeded event, none of the events (onerror, onabort, oncomplete) will fire and starting a new transaction later on will fail because IndexedDB thinks there is still a version upgrade transaction active (error message: "A version change transaction is running.").
<rdar://problem/107474101>