How to uninstall old versions of postgres?

AI-generated summary

Nacho_Caballero has multiple versions of Postgres installed on their server and is experiencing issues when restarting the service. Falco clarifies that this issue is unrelated to Discourse, as it ships with PostgreSQL inside a container image. According to Falco, Discourse currently uses Postgres 12 by default and plans to migrate to Postgres 13 soon.

I’ve noticed that my server has several versions of postgres installed:

grep -H '^port' /etc/postgresql/*/main/postgresql.conf
/etc/postgresql/10/main/postgresql.conf:port = 5432				# (change requires restart)
/etc/postgresql/12/main/postgresql.conf:port = 5434				# (change requires restart)
/etc/postgresql/13/main/postgresql.conf:port = 5435				# (change requires restart)

I think this might be causing problems when starting/stopping the postgresql service via service postgresql restart.

I have two questions:

  1. Which one does the latest version of Discourse use?
  2. How can I safely uninstall the other versions?

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.