Database migration lock after updating ghost

I realise that this question has already been asked before and I apologise for raising it again but none of the solutions have worked for me.

I’ve been running Ghost on a Google Cloud Run instance for a while and just recently updated from version 5.4.1 to version 5.25.2.
After the upgrade, the instance fails with the message

MigrationsAreLockedError: Migration lock was never released or currently a migration is running..

Initially I thought it was the MySQL version. I was running CloudSQL with MySQL 5.7 but I did an in-place upgrade to MySQL 8. That did not solve the issue.

The other fix I tried was setting the lock entry in the migrations_lock table to 0
i.e. UPDATE migrations_lock SET locked=0 WHERE lock_key='km01' and that hasn’t worked as well.

Downgrading versions doesn’t work either and I can’t go back to version 5.4.1 because of the vulnerability

I also came across the following comment Migration locked / migrations and migrations_lock are empty · Issue #9404 · TryGhost/Ghost · GitHub that suggested deleting the migrations and migrations_lock tables, but I’m very skeptical about that. The comment also has a number of downvotes.

Does anyone have any idea on how to fix this issue?