The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Module::Build::Database::PostgreSQL - PostgreSQL implementation for MBD

SYNOPSIS

In Build.PL :

 my $builder = Module::Build::Database->new(
     database_type => "PostgreSQL",
     database_options => {
         name   => "my_database_name",
         schema => "my_schema_name",
         # Extra items for scratch databases :
         append_to_conf => "text to add to postgresql.conf",
         after_create => q[create schema audit;],
     },
     database_extensions => {
         postgis     => { schema => "public", },
         # directory with postgis.sql and spatial_ref_sys.sql
         postgis_base => '/usr/local/share/postgresql/contrib'
     },
 );

DESCRIPTION

Postgres driver for Module::Build::Database.

OPTIONS

All of the options above may be changed via the Module::Build option handling, e.g.

  perl Build.PL --database_options name=my_name
  perl Build.PL --postgis_base=/usr/local/share/postgresql/contrib

The options are as follows ;

name

the name of the database (i.e. 'create database $name')

schema

the name of the schema to be managed by MBD

append_to_conf

extra options to append to postgresql.conf before starting test instances of postgres

after_create

extra SQL to run after running a 'create database' statement. Note that this will be run in several different situations :

  1. during a dbtest (creating a test db)

  2. during a dbfakeinstall (also creating a test db)

  3. during an initial dbinstall; when the target database does not yet exist.

An example of using the after_create statement would be to create a second schema which will not be managed by MBD, but on which the MBD-managed schema depends.

database_extension

To specify a server side procedural language you can use the database_extension -> languages option, like so:

 my $builder = Module::Build::Database->new(
   database_extension => {
     languages => [ 'plperl', 'pltcl' ],
   },
 );

Trying to create languages to a patch will not work because they not stored in the main schema and will not be included in base.sql when you run Build dbdist.

This is also similar to

 after_create => 'create extension ...',

except it is executed on every dbinstall meaning you can use this to add extensions to existing database deployments.

NOTES

The environment variables understood by psql: PGUSER, PGHOST and PGPORT will be used when connecting to a live database (for dbinstall and fakeinstall). PGDATABASE will be ignored; the name of the database should be specified in Build.PL instead.