typoes
[migration-tools.git] / mig-bin / mig-stagebibs
index f706d7d..1801f02 100755 (executable)
@@ -48,7 +48,7 @@ my $next_arg_is_file = 0;
 my $append = 0;
 my $next_arg_is_source = 0;
 my $next_arg_is_stage = 0;
-my $stage_table = 'biblio_record_entry';
+my $stage_table = 'biblio_record_entry_legacy';
 my $source = 'default';
 my $file_is_xml = 0;
 my $dbh = Mig::db_connect();
@@ -79,7 +79,9 @@ foreach my $arg (@ARGV) {
 }
 
 my $bre_test = check_for_table($dbh,'biblio_record_entry');
-if ($bre_test == 0) { create_child_bre($dbh); }
+my $bre_legacy_test = check_for_table($dbh,'biblio_record_entry_legacy');
+if ($bre_test == 0 and $bre_legacy_test == 0 ) { create_child_bre($dbh); rename_child_bre($dbh); }
+if ($bre_test == 1 and $bre_legacy_test == 0 ) { rename_child_bre($dbh); }
 
 my $xmig_test = check_for_column($dbh,'biblio_record_entry','x_migrate');
 if ($xmig_test == 0) { add_column($dbh,'biblio_record_entry','x_migrate','BOOLEAN DEFAULT TRUE'); }
@@ -124,6 +126,16 @@ sub create_child_bre {
     return ();
 }
 
+sub rename_child_bre {
+    my $dbh = shift;
+    $dbh->do("DO \$\$ 
+        BEGIN
+        ALTER TABLE biblio_record_entry RENAME TO biblio_record_entry_legacy;
+        END \$\$;");
+
+    return ();
+}
+
 sub abort {
     my $msg = shift;
     print STDERR "$0: $msg", "\n";