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
postgresql.conf
extra SQL to run after running a 'create database' statement. Note that this will be run in several different situations :
during a dbtest (creating a test db)
during a dbfakeinstall (also creating a test db)
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:
database_extension
languages
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.
base.sql
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.
psql
PGUSER
PGHOST
PGPORT
PGDATABASE
To install Module::Build::Database, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Build::Database
CPAN shell
perl -MCPAN -e shell install Module::Build::Database
For more information on module installation, please visit the detailed CPAN module installation guide.