2
votes

I am aware of this question which talks about using SELECT PostGIS_full_version(); but this requires you have a database on which the postgis extension is installed.

I am using a fabric to write a program to check if postgis (above a particular version) is installed on a server and if not, install it. Is this possible?

2

2 Answers

4
votes

Every Postgres server contains a database called postgres.

You can connect to this database and query the pg_available_extensions or pg_available_extension_versions tables to see which versions of PostGIS are installed on the server.

0
votes

You can connect to the postgres database (created when postgresql is installed) and execute

SELECT extversion
FROM pg_catalog.pg_extension
WHERE extname='postgis'

If you get a result, it will be the postgis version.