View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Brian Duggan > Module-Build-Database-0.50 > Module::Build::Database::PostgreSQL



Annotate this POD


Open  0
View/Report Bugs
Source   Latest Release: Module-Build-Database-0.57


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


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'


Postgres driver for Module::Build::Database.


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 ;


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


the name of the schema to be managed by MBD


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


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.


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.


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.

syntax highlighting: