According to the official documentation on the topic, you have to create the extension in each new database you create. Why? This has to do with a change in the way a database is PostGIS-enabled in PostgreSQL-9.1+ and PostGIS-2+. Previously, there were a series of scripts that had to be run to load the functions, types, and other features of PostGIS into a database. Consequently, the best practice was to create a template database (template_postgis
, etc.), run all the scripts against that template, and create each new PostGIS-enabled database against that template. In newer versions of PostgreSQL (9.1+), you can enabled PostGIS support within a new database by simply executing the command CREATE EXTENSION postgis
; as such, you should skip the template step entirely.
So to sum up:
CREATE EXTENSION postgis;
is the way to go for PostgreSQL-9.1+ and PostGIS-2+- Making a template database is the way to go for prior versions of PostgreSQL or PostGIS.
I hope that helps clear it up!