The gallery needs a change like this one.  Or, you could just use the onupgradeend event.