How to upgrade gogs (docker) from 0.11.x to 0.12.x?

I am currently using gogs 0.11.91 as a docker container with a mysql 5.7 backend (which also runs in a container is connected to gogs via a docker network using docker-compose).

I today tried to upgrade to gogs 0.12.3, which failed. This version no longer seems to be able to connect to the mysql database.

On the gogs side, I receive the following error:
[error] failed to initialize database, got error failed to connect to host=db user=gogs database=gogs: failed to receive message (unknown message type: J)
On the db side, I get this:
2020-10-16T08:06:17.671572Z 1170 [Note] Got an error reading communication packets
2020-10-16T08:06:18.670974Z 1171 [Note] Got packets out of order

It seems like gogs no longer supports this old (but still extremely common) version of mysql. Is there some kind of upgrade path I can follow to upgrade gogs without losing my data?