BTW: I have already searched for this topic.
I am trying to upgrade our Moodle from 3.5 to 3.9 - which is supposed to be OK.
It may be relevant that the first time I ran the script it timed out - that's my fault for not altering the max_execution setting.
I doubt it is relevant since I then restored the DB and tried again and got:
Table "badge_alignment" already exists.
Restored DB again and thinking maybe the restore hadn't worked properly the first time got the same thing.
Altered /lib/db/upgrade 1189 - which literally refers to badge_alignment putting an if around it to prevent the rename if the table exists.
Debug info: Table 'mdl_h5pactivity' already exists [this was on an attempt to create]
We have h5p and I had followed the advice to download latest versions of non core plugins and put them in the appropriate places in the code base. By the way this is separate from the new code version of H5P.
I don't have much longer to get this done.
I am now in the process of restoring the DB again and next will try restoring a clean code base for 3.9 with no additional plugins and running the upgrade again.
Any advice welcome.