Hmm OK this is tricky but I have a temporary fix out for this.
https://github.com/discourse/discourse/commit/6740631fdb379f764e8d3007447341f4496dc350
The problem here is that the Discourse restorer only migrates table to the backup schema and not functions that we create. The fix here is to ensure that the restorer migrates functions created by the Discourse code base as well but I’ll need to work on a pattern to identify “Discourse PostgreSQL functions”. I’ll probably just namespace the functions that we create with _discourse_
.