From: Jason Etheridge Date: Wed, 3 May 2017 19:21:20 +0000 (-0400) Subject: mig-sql X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=21476f5e1ba0c26fa3a0ae03e006ee03a5e4e280 mig-sql Mig wrapper for psql. Plan is to start injecting some useful mig-tracked variables into psql sessions thus invoked. Signed-off-by: Jason Etheridge --- diff --git a/mig b/mig index ea6cfd1..3f6557b 100755 --- a/mig +++ b/mig @@ -226,6 +226,10 @@ or for all mapped files if no file is specified. Generates _prod.sql for the specified linked and mapped file, or all such files if no file is specified. +=item B [arguments...] + +A wrapper around the psql command. At some point the plan is to shove mig-tracked variables into psql sessions. + =back =cut @@ -317,6 +321,10 @@ switch($ARGV[0]) { Mig::die_if_no_env_migschema(); standard_invocation(@ARGV); } + case "sql" { + Mig::die_if_no_env_migschema(); + standard_invocation(@ARGV); + } case "map" { Mig::die_if_no_env_migschema(); } diff --git a/mig-bin/mig-sql b/mig-bin/mig-sql new file mode 100755 index 0000000..7c0c2ed --- /dev/null +++ b/mig-bin/mig-sql @@ -0,0 +1,42 @@ +#!/usr/bin/perl -w +############################################################################### +=pod + +=head1 NAME + +mig-sql + +A wrapper around the psql command. At some point the plan is to shove mig-tracked variables into psql sessions. + +=head1 SYNOPSIS + +B [arguments...] + +=cut + +############################################################################### + +use strict; +use Switch; +use Env qw( + HOME PGHOST PGPORT PGUSER PGDATABASE MIGSCHEMA + MIGBASEWORKDIR MIGBASEGITDIR MIGGITDIR MIGWORKDIR +); +use Pod::Usage; +use DBI; +use Cwd 'abs_path'; +use FindBin; +my $mig_bin = "$FindBin::Bin/"; +use lib "$FindBin::Bin/"; +use Mig; + +pod2usage(-verbose => 2) if defined $ARGV[0] && $ARGV[0] eq '--help'; + +system( + 'psql', + # TODO inject mig-tracked variables here + @ARGV +); + +exit 0; +