Hello Marco
The bug is caused precisely because running the script, this error occurs in Step 3.
Anyway, I did a test. I downloaded the original version 3.6.8, I uploaded the forum in another folder, and upload my bd run the upgrade script and I have not had any error.
This test confirms that I have a grave error in my original forum.
I ask: You can dump the original version 3.6.8 on my forum to avoid the error when trying to run the upgrade?
Thanks Marco