rewire to match the new naming scheme and layout
[migration-tools.git] / emig.d / bin / mig-stage
index 6e7faf5..62f74a9 100755 (executable)
@@ -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";
     }