I took a look at the upgrade.sh script that it uses and it seems to me that it more just handles migrating files while preserving config and handling the start/stop scripts for the service.

That makes me wonder if you can get away with just not using that at all in your PKGBUILD as the PKGBUILD handles all of that stuff for you.

There is the Upgrade command here [1] on line 22 that it looks like the Docker version uses to run the application upgrades. My assumption would be you could re-purpose that to run the upgrades after a new package install.

[1] https://code.onedev.io/onedev/server/~files/main/server-product/docker/entrypoint.sh