rewire to match the new naming scheme and layout
[migration-tools.git] / emig.d / bin / mig-gsheet
index 5975bd6..c37c021 100755 (executable)
@@ -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];
 }