X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=mig-bin%2FMig.pm;h=f1b97f269922970833e607db7ffe7639f014412d;hp=6600cfda6b4af77f0c9426224424fa76cccc8f32;hb=32f8a87408763d0ace21af526d68ffb02559a33d;hpb=f9201dc2d1699f5161e5e29690a1634e8063bb85 diff --git a/mig-bin/Mig.pm b/mig-bin/Mig.pm index 6600cfd..f1b97f2 100644 --- a/mig-bin/Mig.pm +++ b/mig-bin/Mig.pm @@ -19,13 +19,20 @@ use Env qw( ); sub db_connect { - my $dbh = DBI->connect( + my $dbh; + if ($PGHOST) { + $dbh = DBI->connect( "dbi:Pg:host=$PGHOST;dbname=$PGDATABASE;port=$PGPORT" ,$PGUSER ,undef - ) || die "Unable to connect to $PGHOST:$PGPORT:$PGDATABASE:$PGUSER : $!\n"; + ) || die "Unable to connect to $PGHOST:$PGPORT:$PGDATABASE:$PGUSER : $!\n"; + } else { + $dbh = DBI->connect("dbi:Pg:dbname=$PGDATABASE", "", "") || die "Unable to connect to $PGDATABASE : $!\n"; + } + $dbh->do("SET search_path TO $MIGSCHEMA, evergreen, pg_catalog, public"); return $dbh; } + sub db_disconnect { my $dbh = shift; $dbh->disconnect;