Oke I solved it myself. And this is how I did on my CentOS 8 server.
I restored the database that was working. First I checked if there were no errors inside the database by using the following command.
mysqlcheck --repair --all-databases
Now as mentioned in this topic before I got an duplicate error. So I went to the database.
mysql -u root -p
Opened the database
use osticket;
And entered the following commands.
ALTER TABLE ost_ticket DROP COLUMN ticket_pid;
ALTER TABLE ost_sla DROP COLUMN schedule_id;
quit;
After that I was able to upgrade to the latest version.