App-PGMultiDeploy

 view release on metacpan or  search on metacpan

lib/App/PGMultiDeploy.pm  view on Meta::CPAN


use 5.006;
use strict;
use warnings;
package App::PGMultiDeploy;
use Moo;
use DBI;
use Carp;
use Config::IniFiles;
use PGObject::Util::DBChange;
use Try::Tiny;

=head1 NAME

App::PGMultiDeploy - OO deployment to multiple dbs for Pg

=head1 VERSION

Version 0.004.001

=cut

our $VERSION = 0.004001;


=head1 SYNOPSIS

This package provides a library and a command line utility to run sql scripts
on multiple pg databases relying on two phase commit to ensure the script 
succeeds or fails.  Scripts can only be applied once and the intended use is to
manage schema changes over time in databases subject to row-level logical
replication.

Features:

=over

=item Recovery for partial application

A change file is not re-applied if it has been applied before unless the file
has changed.  This means if another system using PGObject::Util::DBChange 
applies a file to one db, you can still safely use it here.

=item Two phase commit

A change file either commits or rolls back on every database in a group

=item Reuse of libpq tooling

.pgpass etc files work with this tool

=item Logging of failures in separate transaction

=back

Use as a library:

    use App::PGMultiDeploy;

    my $foo = App::PGMultiDeploy->new( config_file => 'path/to/conf.ini',
                                       change_file => 'path/to/change.sql',
                                       dbgroup => 'defined_in_config');
    $foo->deploy;

use as a commandline:

    pg_multideploy --config=/path/to/conf.ini --sql=mychanges.sql --dbgroup=foo

=head1 PROPERTIES

=head2 config_file (--config)



( run in 1.898 second using v1.01-cache-2.11-cpan-39bf76dae61 )