There's a few ways to accomplish this. As others have mentioned, pg_catalog isn't the best way to go about this. From a schema perspective, you can install it in public or even better, create a dedicated schema for all extensions (i.e. create schema extensions;) and then place all of your extensions in there. My preference is to go with the dedicated extensions schema and then make sure the extensions schema is part of the search_path.
To have pgcrypto (and any author extensions) get installed automatically when you run a create database, you can create the extensions schema in the template 1 database and install the needed extensions there. Alternatively, if you don't want to mess with the template 1 database, you can create a new template database and then set that to be the default by issuing an ALTER DATABASE ... IS_TEMPLATE TRUE; (see https://www.postgresql.org/docs/current/sql-alterdatabase.html). Personally, if I was doing this, I'd automate this with ansible (or your favorite automation tool) and have the automation code create the database, create the extensions schema, create the extensions in the new schema, and finally set the search_path,. Best Regards, Tim On Fri, Sep 18, 2026 at 9:44 AM Karsten Hilbert <[email protected]> wrote: > Am Fri, Sep 18, 2026 at 02:33:33PM +0000 schrieb Phil Rau: > > > The question now becomes: Is there a way to set up an instance such > that any new databases created underneath it automatically get a given > extension (in this case pgcrypto)? What is the best practice to do this? > > Isn't the canonical way for that to install it into a > template database from which new databases get created > eventually ? > > Karsten > -- > GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B > > >
