Héctor,
regarding bug #2092, did you apply the patch before running the script ?
what version are you upgrading for ?
as i was submitting the bug someone observed that such script should only be needed if you are upgrading from 5.0.x versions, and you should skip it by renaming it to something like 5.0.99-5.1.0 (i actually just removed it).