How to uninstall old versions of postgres?

Sorry but what does this have to do with Discourse? Discourse ships with PostgreSQL inside the container image, so we are not involved with any software installed on your server.

➜  discoursesmall git:(6a42acbf) docker run --rm -it discourse/base:2.0.20201125-2246
root@f89c549fdef1:/# ls /etc/postgresql
12

By default, none since it uses the container one. If talking only about versions, we are currently using 12 and will migrate to 13 very soon.