X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=mig-bin%2Fmig-stagebibs;h=1801f02ef06ce70bf4868dbd6a54cf06ed62249e;hp=f706d7d681b07ecfbb30f5a29ba5d9a35a9347ed;hb=3282699cdc8a2f7701617f496588d4fad3641467;hpb=5e56a7f584e2dc5abf235d327c867732239aa7b4 diff --git a/mig-bin/mig-stagebibs b/mig-bin/mig-stagebibs index f706d7d..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'); } @@ -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";