From: Jason Etheridge Date: Fri, 10 Apr 2020 18:28:17 +0000 (-0400) Subject: rewire to match the new naming scheme and layout X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=a74fb96ef0ac37554e3a34a15083ca38a42c190a rewire to match the new naming scheme and layout --- diff --git a/emig b/emig index 3d53a6c..6f43552 100755 --- a/emig +++ b/emig @@ -283,9 +283,9 @@ use Env qw( ); use Pod::Usage; use FindBin; -my $mig_bin = "$FindBin::Bin/mig-bin/"; -use lib "$FindBin::Bin/mig-bin"; -use Mig; +my $mig_bin = "$FindBin::Bin/emig.d/bin/"; +use lib "$FindBin::Bin/emig.d/bin"; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0]; switch($ARGV[0]) { @@ -322,7 +322,7 @@ switch($ARGV[0]) { sub standard_invocation { my $cmd = shift; - if ($cmd ne 'env') { Mig::die_if_no_env_migschema(); } + if ($cmd ne 'env') { EMig::die_if_no_env_migschema(); } if (-e $mig_bin . "mig-$cmd") { system( $mig_bin . "mig-$cmd", @_ ); } else { diff --git a/emig.d/bin/Mig.pm b/emig.d/bin/EMig.pm similarity index 99% rename from emig.d/bin/Mig.pm rename to emig.d/bin/EMig.pm index f1b97f2..29d0cd3 100644 --- a/emig.d/bin/Mig.pm +++ b/emig.d/bin/EMig.pm @@ -1,4 +1,4 @@ -package Mig; +package EMig; use strict; use Exporter; diff --git a/emig.d/bin/mig-add b/emig.d/bin/mig-add index 3e433c5..c09f566 100755 --- a/emig.d/bin/mig-add +++ b/emig.d/bin/mig-add @@ -38,12 +38,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $has_headers = 1; my $headers_file; @@ -99,7 +99,7 @@ sub add_this_file { return; } } - if (Mig::check_for_tracked_file($file)) { + if (EMig::check_for_tracked_file($file)) { print "File already tracked: $file\n"; } else { print 'Adding ('; @@ -109,7 +109,7 @@ sub add_this_file { print ($headers ? ' with headers' : 'without headers'); } print '): ' . "$file\n"; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $rv = $dbh->do(" INSERT INTO $MIGSCHEMA.tracked_file ( base_filename @@ -121,7 +121,7 @@ sub add_this_file { ," . $dbh->quote($headers_file) . " ); ") || die "Error inserting into table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } } diff --git a/emig.d/bin/mig-bibstats b/emig.d/bin/mig-bibstats index e0db266..432feeb 100755 --- a/emig.d/bin/mig-bibstats +++ b/emig.d/bin/mig-bibstats @@ -38,7 +38,7 @@ use Cwd qw(getcwd); use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; use open ':encoding(utf8)'; pod2usage(-verbose => 2) if defined $ARGV[0] && $ARGV[0] eq '--help'; diff --git a/emig.d/bin/mig-clean b/emig.d/bin/mig-clean index b9cb013..c423cb6 100755 --- a/emig.d/bin/mig-clean +++ b/emig.d/bin/mig-clean @@ -48,12 +48,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $file = abs_path($ARGV[0]); if ($file =~ /^$MIGBASEWORKDIR/) { @@ -70,9 +70,9 @@ sub call_clean_csv { my $file = abs_path(shift); my @args = @_; - my $tracked_file_id = Mig::check_for_tracked_file($file); + my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - my $data = Mig::status_this_file($file); + my $data = EMig::status_this_file($file); if (! $data->{'utf8_filename'}) { die "mig-iconv or mig-skip-iconv needed for UTF8 version of file: $file\n"; @@ -107,7 +107,7 @@ sub call_clean_csv { print join(' ',@args) . "\n"; system('clean_csv', @args, $utf8_file); - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $clean_file = $dbh->quote($utf8_file . '.clean'); if (! -e $utf8_file . '.clean') { print "clean file does not exist: $clean_file\n"; @@ -120,7 +120,7 @@ sub call_clean_csv { WHERE base_filename = " . $dbh->quote($file) . " ; ") || die "Error inserting into table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } else { print "File not currently tracked: $file\n"; } diff --git a/emig.d/bin/mig-convert b/emig.d/bin/mig-convert index 6fe2172..215cd3f 100755 --- a/emig.d/bin/mig-convert +++ b/emig.d/bin/mig-convert @@ -47,12 +47,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $file = abs_path($ARGV[0]); if ($file =~ /^$MIGBASEWORKDIR/) { @@ -70,9 +70,9 @@ sub call_convert_csv { my @args = @_; my $stage_sql_filename; - my $tracked_file_id = Mig::check_for_tracked_file($file); + my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - my $data = Mig::status_this_file($file); + my $data = EMig::status_this_file($file); if (! $data->{'utf8_filename'}) { die "mig-iconv or mig-skip-iconv needed for UTF8 version of file: $file\n"; @@ -112,7 +112,7 @@ sub call_convert_csv { print "args: " . join(',',@args) . "\n"; system('csv2sql', @args, $clean_file); - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); if (! -e $stage_sql_filename) { print "SQL converted file does not exist: $stage_sql_filename\n"; $stage_sql_filename = ''; @@ -124,7 +124,7 @@ sub call_convert_csv { WHERE base_filename = " . $dbh->quote($file) . " ; ") || die "Error updating table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } else { print "File not currently tracked: $file\n"; } diff --git a/emig.d/bin/mig-dump b/emig.d/bin/mig-dump index 57edeab..f741209 100755 --- a/emig.d/bin/mig-dump +++ b/emig.d/bin/mig-dump @@ -31,7 +31,7 @@ use Cwd qw(getcwd); use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; use open ':encoding(utf8)'; pod2usage(-verbose => 2) if defined $ARGV[0] && $ARGV[0] eq '--help'; diff --git a/emig.d/bin/mig-env b/emig.d/bin/mig-env index dceec4f..7ed2b71 100755 --- a/emig.d/bin/mig-env +++ b/emig.d/bin/mig-env @@ -22,7 +22,7 @@ B =head1 DESCRIPTION For most invocations, B will either create or use a migration-specific -file (~/.mig/.env) for setting the following environment +file (~/.emig/.env) for setting the following environment variables: =over 15 @@ -74,12 +74,12 @@ and migration work directory (which will also be created if needed). =item B This command will spawn a bash shell that executes the corresponding -~/.mig/.env script for setting up environment variables encoded during +~/.emig/.env script for setting up environment variables encoded during B. =item B [schema] -This command will show the contents of the corresponding ~/.mig/.env +This command will show the contents of the corresponding ~/.emig/.env script, or, if no schema is specified, then it will list pertinent variables in the current environment if they exist. @@ -91,7 +91,7 @@ separate schema name. =item B -This command will list migration schemas found in ~/.mig +This command will list migration schemas found in ~/.emig =item B @@ -119,7 +119,7 @@ use lib "$FindBin::Bin/"; pod2usage(-verbose => 2) if ! $ARGV[0]; my $migration_schema = $ARGV[1] || ''; -my $filename = "$HOME/.mig/$migration_schema.env"; +my $filename = "$HOME/.emig/$migration_schema.env"; switch($ARGV[0]) { case "--help" { pod2usage(-verbose => 2); @@ -134,7 +134,7 @@ switch($ARGV[0]) { case "clone" { pod2usage(-verbose => 1) if ! $ARGV[2]; $migration_schema = $ARGV[2] || ''; - $filename = "$HOME/.mig/$migration_schema.env"; + $filename = "$HOME/.emig/$migration_schema.env"; mig_env_clone(); } case "use" { @@ -153,7 +153,7 @@ switch($ARGV[0]) { } } case "list" { - opendir(my $dh, "$HOME/.mig") || die "can't open $HOME/.mig: $!"; + opendir(my $dh, "$HOME/.emig") || die "can't open $HOME/.emig: $!"; while (readdir $dh) { if (/^(.*)\.env$/) { print "$1\n"; @@ -231,7 +231,7 @@ sub mig_env_create { # create files and directories if needed - mkdir "$HOME/.mig"; + mkdir "$HOME/.emig"; make_path($MIGGITDIR, { verbose => 1 }); `touch $MIGGITDIR/README`; make_path($MIGWORKDIR, { verbose => 1 }); @@ -259,7 +259,7 @@ sub mig_env_create { sub mig_env_clone { my $orig_migration_schema = $ARGV[1] || ''; - my $orig_filename = "$HOME/.mig/$orig_migration_schema.env"; + my $orig_filename = "$HOME/.emig/$orig_migration_schema.env"; `cp $orig_filename $filename`; `sed -i 's/export PGOPTIONS=.*/export PGOPTIONS='"'"'-c search_path=$migration_schema,public,evergreen'"'"'/' $filename`; `sed -i 's/export MIGENVPROMPT=.*/export MIGENVPROMPT=$migration_schema/' $filename`; diff --git a/emig.d/bin/mig-gsheet b/emig.d/bin/mig-gsheet index 5975bd6..c37c021 100755 --- a/emig.d/bin/mig-gsheet +++ b/emig.d/bin/mig-gsheet @@ -12,7 +12,7 @@ use DBI; use FindBin; use lib "$FindBin::Bin/"; my $mig_bin = "$FindBin::Bin/"; -use Mig; +use EMig; use strict; use Switch; use Cwd 'abs_path'; @@ -22,7 +22,7 @@ use DateTime; pod2usage(-verbose => 2) if defined $ARGV[0] && $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); +EMig::die_if_no_env_migschema(); die_if_gsheet_tracked_table_does_not_exist(); die_if_gsheet_tracked_column_does_not_exist(); @@ -37,7 +37,7 @@ my $sql; my $sth; my @ws; my @tracked_ws_names; -my $authfile = $ENV{HOME} . '/.mig/oauth.env'; +my $authfile = $ENV{HOME} . '/.emig/oauth.env'; my $next_arg_is_authfile; foreach my $arg (@ARGV) { @@ -89,7 +89,7 @@ while (my $var = <$fh>) { if ($var1 eq 'CLIENTSECRET') { $clientsecret = $var2; } if ($var1 eq 'SESSIONFILE') { $sessionfile = $var2; } } -my $dbh = Mig::db_connect(); +my $dbh = EMig::db_connect(); my $spreadsheet = connect_gsheet($clientid,$clientsecret,$sessionfile); abort('could not connect to google sheet') unless (defined $spreadsheet); @@ -244,7 +244,7 @@ sub get_pg_column_headers { my $table_name = shift; my $schema_name = shift; my @headers; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); $sql = 'SELECT column_name FROM information_schema.columns WHERE table_schema = ' . $dbh->quote( $schema_name ) . ' AND table_name = ' . $dbh->quote( $table_name ) . ';'; $sth = $dbh->prepare($sql); $ra = $sth->execute(); @@ -271,7 +271,7 @@ sub erase_sheet { } sub check_for_gsheet_tracked_table { - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT EXISTS( SELECT 1 @@ -284,7 +284,7 @@ sub check_for_gsheet_tracked_table { || die "Error checking for table (tracked_gsheet_table): $!"; my @cols = $sth->fetchrow_array; $sth->finish; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); return $cols[0]; } @@ -327,7 +327,7 @@ sub get_table_name { sub check_for_gsheet_tracked_column { - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT EXISTS( SELECT 1 @@ -340,7 +340,7 @@ sub check_for_gsheet_tracked_column { || die "Error checking for table (gsheet_tracked_column): $!"; my @cols = $sth->fetchrow_array; $sth->finish; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); return $cols[0]; } diff --git a/emig.d/bin/mig-iconv b/emig.d/bin/mig-iconv index 88acdd0..6bf22be 100755 --- a/emig.d/bin/mig-iconv +++ b/emig.d/bin/mig-iconv @@ -47,12 +47,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $file = abs_path($ARGV[0]); if ($file =~ /^$MIGBASEWORKDIR/) { @@ -69,9 +69,9 @@ sub call_iconv { my $file = abs_path(shift); my @args = @_; - my $tracked_file_id = Mig::check_for_tracked_file($file); + my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - my $data = Mig::status_this_file($file); + my $data = EMig::status_this_file($file); print "iconv'ing tracked file: $file\n"; if (scalar(@args) == 0) { @@ -87,7 +87,7 @@ sub call_iconv { system('iconv', @args, '-o', $file . '.utf8', $file); system('touch', $file . '.utf8'); # handle 0-byte files - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $utf8_file = $dbh->quote($file . '.utf8'); if (! -e $file . '.utf8') { print "utf8 file does not exist: $utf8_file\n"; @@ -100,7 +100,7 @@ sub call_iconv { WHERE base_filename = " . $dbh->quote($file) . " ; ") || die "Error inserting into table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } else { print "File not currently tracked: $file\n"; } diff --git a/emig.d/bin/mig-init b/emig.d/bin/mig-init index 98f92b5..fb3d9ce 100755 --- a/emig.d/bin/mig-init +++ b/emig.d/bin/mig-init @@ -31,23 +31,23 @@ use Pod::Usage; use DBI; use FindBin; my $mig_bin = "$FindBin::Bin/"; -my $mig_sql = $mig_bin . "../mig-sql/init/"; +my $mig_sql = $mig_bin . "../sql/init/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if $ARGV[0]; -Mig::die_if_no_env_migschema(); +EMig::die_if_no_env_migschema(); -if (! Mig::check_for_db_migschema()) { +if (! EMig::check_for_db_migschema()) { try_to_create_schema(); } -if (! Mig::check_db_migschema_for_migration_tables()) { +if (! EMig::check_db_migschema_for_migration_tables()) { try_to_init_schema_with_migration_tools(); } -Mig::die_if_mig_tracking_table_exists(); -Mig::die_if_mig_column_tracking_table_exists(); +EMig::die_if_mig_tracking_table_exists(); +EMig::die_if_mig_column_tracking_table_exists(); loop_through_mig_sql_templates(); exit 0; @@ -58,24 +58,24 @@ sub try_to_create_schema { if ($MIGSCHEMA =~ /[^\w_]/) { die "$MIGSCHEMA is not suitable for a schema name in PostgreSQL\n"; } - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $rv = $dbh->do("CREATE SCHEMA $MIGSCHEMA;") || die "Error creating migration schema ($MIGSCHEMA): $!\n"; print "Created schema $MIGSCHEMA\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } sub try_to_init_schema_with_migration_tools { - Mig::die_if_no_migration_tools(); + EMig::die_if_no_migration_tools(); print "Calling migration_tools.init() and .build()\n"; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $rv = $dbh->do("SELECT migration_tools.init(" . $dbh->quote($MIGSCHEMA) . ");") || die "Error running migration_tools.init($MIGSCHEMA): $!\n"; print "migration_tools.init() finished\n"; my $rv2 = $dbh->do("SELECT migration_tools.build(" . $dbh->quote($MIGSCHEMA) . ");") || die "Error running migration_tools.build($MIGSCHEMA): $!\n"; print "migration_tools.build() finished\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } sub loop_through_mig_sql_templates { diff --git a/emig.d/bin/mig-link b/emig.d/bin/mig-link index 1a8ccd7..0c1d42b 100755 --- a/emig.d/bin/mig-link +++ b/emig.d/bin/mig-link @@ -28,12 +28,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $file = abs_path($ARGV[0]); if ($file =~ /^$MIGBASEWORKDIR/) { @@ -50,17 +50,17 @@ sub link_table { my $file = abs_path(shift); my $table = shift; - if (! Mig::check_db_migschema_for_specific_table($table)) { + if (! EMig::check_db_migschema_for_specific_table($table)) { die "table not found in MIGSCHEMA ($MIGSCHEMA): $table\n"; } - my $tracked_file_id = Mig::check_for_tracked_file($file); + my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - my $data = Mig::status_this_file($file); + my $data = EMig::status_this_file($file); print "linking file to parent table: $file -> $table\n"; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT base_filename FROM $MIGSCHEMA.tracked_file @@ -80,7 +80,7 @@ sub link_table { WHERE base_filename = " . $dbh->quote($file) . " ; ") || die "Error updating table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } else { print "File not currently tracked: $file\n"; } diff --git a/emig.d/bin/mig-mapper b/emig.d/bin/mig-mapper index 6841cf7..88e057a 100755 --- a/emig.d/bin/mig-mapper +++ b/emig.d/bin/mig-mapper @@ -36,19 +36,19 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $column_filter = 1; # show all fields my $file = abs_path($ARGV[0]); my $fdata; -my $tracked_file_id = Mig::check_for_tracked_file($file); +my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - $fdata = Mig::status_this_file($file); + $fdata = EMig::status_this_file($file); } else { die "File not currently tracked: $file\n"; } @@ -131,7 +131,7 @@ sub table_menu { printf "%-30s", "---------"; printf "%-30s", "--------------"; print "\n"; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT * FROM information_schema.columns @@ -177,12 +177,12 @@ sub table_menu { print "\n"; $sth->finish; $sth2->finish; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } sub column_menu { my $dtd_identifier = shift; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT * FROM information_schema.columns @@ -194,7 +194,7 @@ sub column_menu { || die "Error retrieving data from information_schema: $!"; my $data = $sth->fetchrow_hashref; $sth->finish; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); my $column = $data->{column_name}; @@ -285,12 +285,12 @@ sub column_menu { sub list_ten { my $column = shift; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth; my $rv; my @cols; - $sth = $dbh->prepare(Mig::sql(" + $sth = $dbh->prepare(EMig::sql(" SELECT " . (defined $column ? $column : '*') . " FROM $MIGSCHEMA.$table LIMIT 10; @@ -339,7 +339,7 @@ sub summarize { my $min_value_as_timestamptz; my $max_value_as_timestamptz; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth; my $rv; my @cols; @@ -611,7 +611,7 @@ sub summarize { $sth->finish; $max_value_as_timestamptz = $cols[0]; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); print "\n"; print "# of rows = $count\n"; @@ -649,11 +649,11 @@ sub summarize { sub group_browse { my ($column,$option) = (shift,shift||"GROUP BY 1 ORDER BY 1"); - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth; my $rv; - $sth = $dbh->prepare(Mig::sql(" + $sth = $dbh->prepare(EMig::sql(" SELECT $column, COUNT(*) FROM $MIGSCHEMA.$table $option; @@ -680,8 +680,8 @@ sub group_browse { sub add_this_column { my $column = shift; - if (!Mig::check_for_tracked_column($table,$column)) { - my $dbh = Mig::db_connect(); + if (!EMig::check_for_tracked_column($table,$column)) { + my $dbh = EMig::db_connect(); my $rv = $dbh->do(" INSERT INTO $MIGSCHEMA.tracked_column ( base_filename @@ -695,19 +695,19 @@ sub add_this_column { ," . $dbh->quote($column) . " ); ") || die "Error inserting into table $MIGSCHEMA.tracked_column: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } } sub status_this_column { my $column = shift; - my $data = Mig::status_this_column($table,$column); + my $data = EMig::status_this_column($table,$column); if (!$data) { add_this_column($column); - $data = Mig::status_this_column($table,$column); + $data = EMig::status_this_column($table,$column); } if ($$data{parent_table}) { - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT * FROM $MIGSCHEMA.fields_requiring_mapping @@ -723,7 +723,7 @@ sub status_this_column { $$data{required} = 0; } $sth->finish; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } return $data; } @@ -732,13 +732,13 @@ sub set_comment { my ($column,$comment) = (shift,shift); if ($comment) { my $data = status_this_column($column); - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $rv = $dbh->do(" UPDATE $MIGSCHEMA.tracked_column SET comment = " . $dbh->quote($comment) . " WHERE id = " . $dbh->quote($data->{id}) . "; ") || die "Error updating table $MIGSCHEMA.tracked_column: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } } @@ -746,13 +746,13 @@ sub set_transform { my ($column,$transform) = (shift,shift); if ($transform) { my $data = status_this_column($column); - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $rv = $dbh->do(" UPDATE $MIGSCHEMA.tracked_column SET transform = " . $dbh->quote($transform) . " WHERE id = " . $dbh->quote($data->{id}) . "; ") || die "Error updating table $MIGSCHEMA.tracked_column: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } } @@ -766,13 +766,13 @@ sub set_target { $target_column = $2; } my $data = status_this_column($column); - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $rv = $dbh->do(" UPDATE $MIGSCHEMA.tracked_column SET target_table = " . $dbh->quote($target_table) . " ,target_column = " . $dbh->quote($target_column) . " WHERE id = " . $dbh->quote($data->{id}) . "; ") || die "Error updating table $MIGSCHEMA.tracked_column: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } } diff --git a/emig.d/bin/mig-quick b/emig.d/bin/mig-quick index 59b0843..b262e03 100755 --- a/emig.d/bin/mig-quick +++ b/emig.d/bin/mig-quick @@ -39,7 +39,7 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; my @files = grep {!/^--/} @ARGV; my %pass_thru = ('add'=>[],'skip-iconv'=>[],'clean'=>[],'convert'=>[],'stage'=>[]); diff --git a/emig.d/bin/mig-quicksheet b/emig.d/bin/mig-quicksheet index 22ed33e..ce371ef 100755 --- a/emig.d/bin/mig-quicksheet +++ b/emig.d/bin/mig-quicksheet @@ -54,7 +54,7 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; my $outtable = ''; my $outfile = ''; @@ -79,8 +79,8 @@ if (! $outtable && ! $outfile) { } } -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $workbook; my @worksheets = (); @@ -111,15 +111,15 @@ if (!$drop) { } close_workbook(); } else { - if (Mig::check_db_migschema_for_specific_table($outtable)) { + if (EMig::check_db_migschema_for_specific_table($outtable)) { drop_existing_outtable(); } } sub handle_file { - my $tracked_file_id = Mig::check_for_tracked_file($file); + my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - $fdata = Mig::status_this_file($file); + $fdata = EMig::status_this_file($file); } else { die "File not currently tracked: $file\n"; } @@ -143,7 +143,7 @@ sub init_workbook { } } if ($outtable) { - if (Mig::check_db_migschema_for_specific_table($outtable)) { + if (EMig::check_db_migschema_for_specific_table($outtable)) { if ($force) { drop_existing_outtable(); } else { @@ -157,7 +157,7 @@ sub init_workbook { sub drop_existing_outtable { # we want a transaction for this one - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; @@ -195,11 +195,11 @@ sub drop_existing_outtable { die "Aborting mig-quicksheet\n"; }; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } sub create_new_outtable { - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); print "Creating table $MIGSCHEMA.$outtable\n"; my $rv = $dbh->do(" CREATE UNLOGGED TABLE $MIGSCHEMA.$outtable ( @@ -207,12 +207,12 @@ sub create_new_outtable { summary_table TEXT UNIQUE ); ") || die "Error creating outtable ($MIGSCHEMA.$outtable): $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } sub create_new_subtable { my $subtable = shift; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; @@ -231,7 +231,7 @@ sub create_new_subtable { die "Aborting mig-quicksheet\n"; }; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } sub write_worksheets { @@ -248,7 +248,7 @@ sub write_worksheets { create_new_subtable( $first_table ); } - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT COUNT(*) FROM $MIGSCHEMA.$table @@ -307,7 +307,7 @@ sub write_worksheets { }; } - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } sub close_workbook { @@ -321,7 +321,7 @@ exit 0; ############################################################################### sub handle_list { - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT * FROM " . $MIGSCHEMA. "." . $table . " @@ -361,7 +361,7 @@ sub handle_list { } sub handle_columns { - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT * FROM information_schema.columns @@ -416,14 +416,14 @@ sub handle_columns { } } $sth->finish; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } sub column_summary { my $column = shift; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); ### non_empty_count my $sth = $dbh->prepare(" @@ -505,7 +505,7 @@ sub column_summary { sub group_by { my ($column,$option) = (shift,"GROUP BY 2 ORDER BY 2"); - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth; my $rv; diff --git a/emig.d/bin/mig-remove b/emig.d/bin/mig-remove index cf70eda..de4f01e 100755 --- a/emig.d/bin/mig-remove +++ b/emig.d/bin/mig-remove @@ -31,12 +31,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); foreach my $arg (@ARGV) { my $file = abs_path($arg); @@ -53,14 +53,14 @@ exit 0; sub remove_this_file { my $file = shift; - my $tracked_file_id = Mig::check_for_tracked_file($file,{'allow_missing'=>1}); + my $tracked_file_id = EMig::check_for_tracked_file($file,{'allow_missing'=>1}); if ($tracked_file_id) { print "removing tracked file: $file\n"; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $rv = $dbh->do(" DELETE FROM $MIGSCHEMA.tracked_file WHERE id = $tracked_file_id; ") || die "Error deleting from table $MIGSCHEMA.tracked_file (id = $tracked_file_id): $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } else { print "File not currently tracked: $file\n"; } diff --git a/emig.d/bin/mig-reporter b/emig.d/bin/mig-reporter index f87059e..8b47a94 100755 --- a/emig.d/bin/mig-reporter +++ b/emig.d/bin/mig-reporter @@ -61,7 +61,7 @@ use Cwd qw(getcwd); use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; use open ':encoding(utf8)'; pod2usage(-verbose => 2) if defined $ARGV[0] && $ARGV[0] eq '--help'; @@ -108,7 +108,7 @@ if (defined $added_page_file or defined $added_page_title) { } if (defined $added_page_file) { $added_page_file = $MIGGITDIR . $added_page_file; } -my $dbh = Mig::db_connect(); +my $dbh = EMig::db_connect(); my $report_file = create_report_name($report_title); $report_file = $MIGGITDIR . $report_file; diff --git a/emig.d/bin/mig-skip-clean b/emig.d/bin/mig-skip-clean index 5b60cb1..9b96d69 100755 --- a/emig.d/bin/mig-skip-clean +++ b/emig.d/bin/mig-skip-clean @@ -32,12 +32,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! ($ARGV[0]||$ARGV[1]) || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $file = abs_path($ARGV[0]); my $clean_file; @@ -64,9 +64,9 @@ sub skip_clean { my $file = shift; my $clean_file = shift; - my $tracked_file_id = Mig::check_for_tracked_file($file); + my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - my $data = Mig::status_this_file($file); + my $data = EMig::status_this_file($file); if (! $data->{'utf8_filename'}) { die "mig-iconv or mig-skip-iconv needed for UTF8 version of file: $file\n"; @@ -79,7 +79,7 @@ sub skip_clean { print "skipping cleaning of tracked file: $file\n"; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); if (! $clean_file) { $clean_file = $utf8_file . '.clean'; } @@ -93,7 +93,7 @@ sub skip_clean { WHERE base_filename = " . $dbh->quote($file) . " ; ") || die "Error inserting into table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } else { die "File not currently tracked: $file\n"; } diff --git a/emig.d/bin/mig-skip-iconv b/emig.d/bin/mig-skip-iconv index fec558d..d12f8a4 100755 --- a/emig.d/bin/mig-skip-iconv +++ b/emig.d/bin/mig-skip-iconv @@ -29,12 +29,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! ($ARGV[0]||$ARGV[1]) || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $file = abs_path($ARGV[0]); my $utf8_file; @@ -61,12 +61,12 @@ sub skip_iconv { my $file = shift; my $utf8_file = shift; - my $tracked_file_id = Mig::check_for_tracked_file($file); + my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - my $data = Mig::status_this_file($file); + my $data = EMig::status_this_file($file); print "skipping the iconv'ing of tracked file: $file\n"; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); if (! $utf8_file) { $utf8_file = $file . '.utf8'; } @@ -80,7 +80,7 @@ sub skip_iconv { WHERE base_filename = " . $dbh->quote($file) . " ; ") || die "Error inserting into table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } else { print "File not currently tracked: $file\n"; } diff --git a/emig.d/bin/mig-sql b/emig.d/bin/mig-sql index 3909ab3..417d47f 100755 --- a/emig.d/bin/mig-sql +++ b/emig.d/bin/mig-sql @@ -29,7 +29,7 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; my @MYARGV = ( 'psql' diff --git a/emig.d/bin/mig-stage b/emig.d/bin/mig-stage index 6e7faf5..62f74a9 100755 --- a/emig.d/bin/mig-stage +++ b/emig.d/bin/mig-stage @@ -34,12 +34,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $file = abs_path($ARGV[0]); if ($file =~ /^$MIGBASEWORKDIR/) { @@ -56,9 +56,9 @@ sub stage_csv { my $file = abs_path(shift); my @args = @_; - my $tracked_file_id = Mig::check_for_tracked_file($file); + my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - my $data = Mig::status_this_file($file); + my $data = EMig::status_this_file($file); if (! $data->{'utf8_filename'}) { die "mig-iconv or mig-skip-iconv needed for UTF8 version of file: $file\n"; @@ -82,7 +82,7 @@ sub stage_csv { my ($schema,$table) = split /\./, $schema_table; if (defined $data->{'staged_table'} && $data->{'staged_table'} ne $table) { - my $dbh2 = Mig::db_connect(); + my $dbh2 = EMig::db_connect(); print "dropping previously staged table: $MIGSCHEMA.$data->{staged_table}\n"; my $rv2 = $dbh2->do(" DROP TABLE $MIGSCHEMA.$data->{staged_table}; @@ -98,7 +98,7 @@ sub stage_csv { SET target_table = " . $dbh2->quote($table) . " WHERE target_table = " . $dbh2->quote($data->{staged_table}) . " ") || die "Error changing references to $data->{staged_table}: $!\n"; - Mig::db_disconnect($dbh2); + EMig::db_disconnect($dbh2); } print "running staging SQL: $stage_sql_filename\n"; @@ -108,20 +108,20 @@ sub stage_csv { if ($schema ne $MIGSCHEMA) { die "Schema mismatch: env => $MIGSCHEMA sql => $schema\n"; } - if (! Mig::check_db_migschema_for_specific_table($table)) { + if (! EMig::check_db_migschema_for_specific_table($table)) { die "Missing staged table: $schema_table\n"; } else { print "table staged: $schema_table\n"; } - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $rv = $dbh->do(" UPDATE $MIGSCHEMA.tracked_file SET staged_table = " . $dbh->quote($table) . " WHERE base_filename = " . $dbh->quote($file) . " ; ") || die "Error updating table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } else { print "File not currently tracked: $file\n"; } diff --git a/emig.d/bin/mig-stagebibs b/emig.d/bin/mig-stagebibs index f045a13..9ce7392 100755 --- a/emig.d/bin/mig-stagebibs +++ b/emig.d/bin/mig-stagebibs @@ -53,7 +53,7 @@ use FindBin; use UNIVERSAL; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; use Getopt::Long; pod2usage(-verbose => 2) if defined $ARGV[0] && $ARGV[0] eq '--help'; @@ -68,7 +68,7 @@ my $serial = ''; my $source = 2; my $x_source = 'default'; my $no_source_or_last_xact_id; -my $dbh = Mig::db_connect(); +my $dbh = EMig::db_connect(); my $infile; my $i = 0; my $batch; diff --git a/emig.d/bin/mig-status b/emig.d/bin/mig-status index 0d78b18..487c9e7 100755 --- a/emig.d/bin/mig-status +++ b/emig.d/bin/mig-status @@ -29,17 +29,17 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if scalar(@ARGV) > 0 && $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my @files = @ARGV; if (scalar(@files) == 0) { @files = (); - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $sth = $dbh->prepare(" SELECT base_filename FROM $MIGSCHEMA.tracked_file @@ -52,12 +52,12 @@ if (scalar(@files) == 0) { push @files, $row->[0] } $sth->finish; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } foreach my $arg (sort @files) { my $file = abs_path($arg); - my $data = Mig::status_this_file($file); + my $data = EMig::status_this_file($file); print "=-=-=\n"; foreach my $key ( 'base_filename' diff --git a/emig.d/bin/mig-unlink b/emig.d/bin/mig-unlink index 5bf34e4..c92aef3 100755 --- a/emig.d/bin/mig-unlink +++ b/emig.d/bin/mig-unlink @@ -29,12 +29,12 @@ use Cwd 'abs_path'; use FindBin; my $mig_bin = "$FindBin::Bin/"; use lib "$FindBin::Bin/"; -use Mig; +use EMig; pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help'; -Mig::die_if_no_env_migschema(); -Mig::die_if_mig_tracking_table_does_not_exist(); +EMig::die_if_no_env_migschema(); +EMig::die_if_mig_tracking_table_does_not_exist(); my $file = abs_path($ARGV[0]); if ($file =~ /^$MIGBASEWORKDIR/) { @@ -50,21 +50,21 @@ exit 0; sub unlink_table { my $file = abs_path(shift); - my $tracked_file_id = Mig::check_for_tracked_file($file); + my $tracked_file_id = EMig::check_for_tracked_file($file); if ($tracked_file_id) { - my $data = Mig::status_this_file($file); + my $data = EMig::status_this_file($file); my $table = $data->{'parent_table'} || ''; print "unlinking table ($table) from file: $file\n"; - my $dbh = Mig::db_connect(); + my $dbh = EMig::db_connect(); my $rv = $dbh->do(" UPDATE $MIGSCHEMA.tracked_file SET parent_table = '' WHERE base_filename = " . $dbh->quote($file) . " ; ") || die "Error updating table $MIGSCHEMA.tracked_file: $!\n"; - Mig::db_disconnect($dbh); + EMig::db_disconnect($dbh); } else { print "File not currently tracked: $file\n"; } diff --git a/kmig b/kmig index 1f6eff2..7feddb9 100755 --- a/kmig +++ b/kmig @@ -4,23 +4,23 @@ =head1 NAME -kmig - git-like program for tracking and manipulating legacy data files for +mig - git-like program for tracking and manipulating legacy data files for migrations. This variant of and is geared toward the Koha ILS and MySql/MariaDB. =head1 SYNOPSIS -B [argument] [...] +B [argument] [...] =head1 DESCRIPTION -B is used to track and manipulate CSV or CSV-like text files exported from +B is used to track and manipulate CSV or CSV-like text files exported from legacy systems for migration into Evergreen. It can be a wrapper for some other migration tools and tracks state using a MySQL table for a given database. For most commands, if the current working directory falls outside of the -directory specified by MIGWORKDIR, then kmig will assume that environment is +directory specified by MIGWORKDIR, then mig will assume that environment is also incorrect and bail before doing any actual work. Only the B and B commands work without the MIGDATABASE environment @@ -28,41 +28,41 @@ variable being set. =head1 OVERVIEW -Using B should go something like this: +Using B should go something like this: =over 15 -=item kmig env create m_foo # Sets up the environment +=item mig env create m_foo # Sets up the environment -=item kmig env use m_foo # Spawns a shell using the configured environment +=item mig env use m_foo # Spawns a shell using the configured environment -=item kmig init # creates any needed auxilary tables +=item mig init # creates any needed auxilary tables -=item kmig add patrons.tsv # tracks an incoming data file; repeat for additional files +=item mig add patrons.tsv # tracks an incoming data file; repeat for additional files -=item kmig iconv patrons.tsv # convert it to UTF8, creating patrons.tsv.utf8 +=item mig iconv patrons.tsv # convert it to UTF8, creating patrons.tsv.utf8 -=item kmig clean patrons.tsv # cleans the file, creating patrons.tsv.utf8.clean +=item mig clean patrons.tsv # cleans the file, creating patrons.tsv.utf8.clean -=item kmig link patrons.tsv borrowers # models the soon-to-be staging table after table 'borrowers' +=item mig link patrons.tsv borrowers # models the soon-to-be staging table after table 'borrowers' -=item kmig convert patrons.tsv # creates a .sql file for staging the data +=item mig convert patrons.tsv # creates a .sql file for staging the data -=item kmig stage patrons.tsv # load said .sql file +=item mig stage patrons.tsv # load said .sql file -=item kmig mapper patrons.tsv # interactive tool for analyzing/mapping the staging table +=item mig mapper patrons.tsv # interactive tool for analyzing/mapping the staging table -=item kmig analysis patrons.tsv # writes a summary .tsv file of mapped/flagged fields from the staging table +=item mig analysis patrons.tsv # writes a summary .tsv file of mapped/flagged fields from the staging table -=item kmig map patrons.tsv # apply configured mappings +=item mig map patrons.tsv # apply configured mappings -=item kmig write_prod patrons.tsv # creates a .sql file for pushing the staging data into production +=item mig write_prod patrons.tsv # creates a .sql file for pushing the staging data into production -=item kmig reporter --analyst "Foo Fooer" --report_title "Foo Load Analysis" #creates an asciidoc report +=item mig reporter --analyst "Foo Fooer" --report_title "Foo Load Analysis" #creates an asciidoc report -=item kmig gsheet --pull foo_tab_name OR --push foo_pg_table_name +=item mig gsheet --pull foo_tab_name OR --push foo_pg_table_name -=item kmig stagebibs --file foo.xml +=item mig stagebibs --file foo.xml =back @@ -99,7 +99,7 @@ Add the specified files to the migration tracker. Until --no-headers is specified, the tracker will assume the files have headers. You can do crazy stuff like -B +B =item B [file] [...] @@ -128,7 +128,7 @@ iconv [other arguments...] -o .utf8 =item B -If this is used instead of B, then B will look for an existing +If this is used instead of B, then B will look for an existing .utf8 and use it instead of attempting to create one. =item B [other arguments...] @@ -154,7 +154,7 @@ clean_csv [other arguments...] =item B -If this is used instead of B, then B will look for an existing +If this is used instead of B, then B will look for an existing .utf8.clean and use it instead of attempting to create one. =item B @@ -241,7 +241,7 @@ Optional parameters are : --added_page_title and --added_page_file If one is used both must be. The added page file can be plain text or asciidoc. This -adds an extra arbitrary page of notes to the report. KMig assumes the page file is in the kmig git directory. +adds an extra arbitrary page of notes to the report. KMig assumes the page file is in the mig git directory. --tags @@ -259,10 +259,10 @@ Allows you to override the default evergreen_staged_report.xml in the mig-xml fo =item B --pull or --push spreadsheet_tab This uses the gsheet_tracked_table and gsheet_tracked column tables to map a Google Docs Spreadsheet tabs -with Postgres tables in the kmig schema. The spreadsheet is assumed to share the name as the kmig schema. +with Postgres tables in the mig schema. The spreadsheet is assumed to share the name as the mig schema. Tab names must be unique. Each spreadsheet column needs a header that matches the column name in the matching -table. An oauth session key is also needed for your Google account and kmig gsheet will look for it in the -.kmig directory. +table. An oauth session key is also needed for your Google account and mig gsheet will look for it in the +.mig directory. =back @@ -318,10 +318,10 @@ sub standard_invocation { my $cmd = shift; if ($cmd ne 'env') { KMig::die_if_no_env_migschema(); } - if (-e $mig_bin . "kmig-$cmd") { - system( $mig_bin . "kmig-$cmd", @_ ); + if (-e $mig_bin . "mig-$cmd") { + system( $mig_bin . "mig-$cmd", @_ ); } else { - system( "kmig-$cmd", @_ ) == 0 or die pod2usage(1); + system( "mig-$cmd", @_ ) == 0 or die pod2usage(1); } } diff --git a/kmig.d/bin/mig-env b/kmig.d/bin/mig-env index a8b5329..2ce6f32 100755 --- a/kmig.d/bin/mig-env +++ b/kmig.d/bin/mig-env @@ -22,7 +22,7 @@ B =head1 DESCRIPTION For most invocations, B will either create or use a migration-specific -file (~/.mig/.env) for setting the following environment +file (~/.kmig/.env) for setting the following environment variables: =over 15 @@ -79,12 +79,12 @@ and migration work directory (which will also be created if needed). =item B This command will spawn a bash shell that executes the corresponding -~/.mig/.env script for setting up environment variables encoded during +~/.kmig/.env script for setting up environment variables encoded during B. =item B [schema] -This command will show the contents of the corresponding ~/.mig/.env +This command will show the contents of the corresponding ~/.kmig/.env script, or, if no schema is specified, then it will list pertinent variables in the current environment if they exist. @@ -98,7 +98,7 @@ separate schema name. =item B -This command will list migration schemas found in ~/.mig +This command will list migration schemas found in ~/.kmig =item B @@ -126,7 +126,7 @@ use lib "$FindBin::Bin/"; pod2usage(-verbose => 2) if ! $ARGV[0]; my $migration_schema = $ARGV[1] || ''; -my $filename = "$HOME/.mig/$migration_schema.env"; +my $filename = "$HOME/.kmig/$migration_schema.env"; switch($ARGV[0]) { case "--help" { pod2usage(-verbose => 2); @@ -141,7 +141,7 @@ switch($ARGV[0]) { case "clone" { pod2usage(-verbose => 1) if ! $ARGV[2]; $migration_schema = $ARGV[2] || ''; - $filename = "$HOME/.mig/$migration_schema.env"; + $filename = "$HOME/.kmig/$migration_schema.env"; mig_env_clone(); } case "use" { @@ -160,7 +160,7 @@ switch($ARGV[0]) { } } case "list" { - opendir(my $dh, "$HOME/.mig") || die "can't open $HOME/.mig: $!"; + opendir(my $dh, "$HOME/.kmig") || die "can't open $HOME/.kmig: $!"; while (readdir $dh) { if (/^(.*)\.env$/) { print "$1\n"; @@ -260,7 +260,7 @@ sub mig_env_create { # create files and directories if needed - mkdir "$HOME/.mig"; + mkdir "$HOME/.kmig"; make_path($MIGGITDIR, { verbose => 1 }); `touch $MIGGITDIR/README`; make_path($MIGWORKDIR, { verbose => 1 });