X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=mig-bin%2Fmig-stagebibs;h=1801f02ef06ce70bf4868dbd6a54cf06ed62249e;hp=0c9bdfdbb27becc92fdb74f744d8af86b108f380;hb=3282699cdc8a2f7701617f496588d4fad3641467;hpb=edd94a43773cd981e352a46dcfc9128b393e2b03 diff --git a/mig-bin/mig-stagebibs b/mig-bin/mig-stagebibs index 0c9bdfd..1801f02 100755 --- a/mig-bin/mig-stagebibs +++ b/mig-bin/mig-stagebibs @@ -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'); } @@ -104,6 +106,7 @@ while(my $line = <$xml>) { } close $xml; +if ($i == 0) { print "No XML was processed, are you sure this is an XML file?\n"; } print "Finis.\n"; # beyond here be functions @@ -123,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";