Hi Tomasz,
Did you rollback DB after error occurs and started script again or you just ran script several times? In this article it's says that: If you experience an error during the SQL script, make sure that you roll back before addressing the causes of the error. Re-applying the script over a partially upgraded database will not work and is not supported.
If yes, the safest will be to revert everything and start with upgrade again, with clean solution and DB.
Best regards,
Dragoljub