Skip to content
arohner edited this page Sep 27, 2011 · 10 revisions

This page describes how to use the features of the Postgres crate. Not all features are currently covered

Settings

The postgres crate stores configuration in a settings map, that looks like

(postgres/settings (postgres/settings-map {:version "8.4"
                                           :permissions [{:connection-type "local" :database "all" :user "all" :auth-method "trust"}]}))

The settings perform no actions, they only provide data for other functions in the crate to consume. Settings may contain the keys :version, :permissions, :options, :recovery.

Permissions

Permissions specify the contents of the pg_hba file. Familiarity with the pg_hba.conf file format is assumed here. For more information, see http://www.postgresql.org/docs/9.0/interactive/auth-pg-hba-conf.html

Permissions is a seq of records, each record is a map, that looks like

{:connection-type "local" :database "all" :user "all" :auth-method "trust"}

The required keys are :connection-type, :database, :user, :auth-method. The optional keys are :ip-mask and :auth-options.

A record can also be a vector

["local" "all "all" "trust"]

The arguments must be in the same order as in a traditional pg_hba.conf

Options

The :options key in the settings map controls values that will go into the postgresql.conf file. It looks like

:options {:port 5432
          :max_connections 100
          :ssl false}

Any key recognized by postgres.conf may be present.

Useful Functions

A non-comprehensive list of functions that are useful. In all cases, the doc strings are helpful.

  • (postgres) Installs postgres
  • (hba-conf) writes the pg_hba.conf file, based on the contents of :permissions in settings. If hba-conf is not called, you will get the postgres default hba.conf.
  • (postgresql-conf) writes the postgresql.conf file, based on the contents of :options
  • (init-db)
  • (create-database)
  • (create-role)
  • (service) Start, stop, restart the postgres service. Note that order is important here, so it may be useful to restart postgres e.g. after writing pg_hba.conf
Clone this wiki locally