From 73ad8d64507f1bcb383037b0652c2e9f68e52085 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 31 Aug 2006 21:13:24 +0000 Subject: [PATCH] updates ... see diff git-svn-id: svn://svn.open-ils.org/ILS/trunk@5817 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Evergreen/src/extras/import/parse_patron_xml.pl | 1 + Open-ILS/src/extras/import/pg_loader.pl | 9 ++++++++- Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm | 6 ++++++ Open-ILS/src/sql/Pg/800.fkeys.sql | 5 +++-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Evergreen/src/extras/import/parse_patron_xml.pl b/Evergreen/src/extras/import/parse_patron_xml.pl index 6b7f038687..f4ccd29576 100755 --- a/Evergreen/src/extras/import/parse_patron_xml.pl +++ b/Evergreen/src/extras/import/parse_patron_xml.pl @@ -210,6 +210,7 @@ for my $patron ( $doc->documentElement->childNodes ) { $a->valid( 'f' ); $a->valid( 't' ) if ($prefix eq 'std_'); + $a->valid( 'f' ) if ($prefix eq 'std_' and $a->findvalue( "${prefix}dpvscore" ) < 3); $a->within_city_limits( 'f' ); $a->country('USA'); diff --git a/Open-ILS/src/extras/import/pg_loader.pl b/Open-ILS/src/extras/import/pg_loader.pl index a1f8552388..7abe5557c3 100755 --- a/Open-ILS/src/extras/import/pg_loader.pl +++ b/Open-ILS/src/extras/import/pg_loader.pl @@ -14,12 +14,13 @@ use Time::HiRes qw/time/; use Getopt::Long; my @files; -my ($config, $output, @auto, @order) = +my ($config, $output, @auto, @order, @wipe) = ('/openils/conf/bootstrap.conf'); GetOptions( 'config=s' => \$config, 'output=s' => \$output, + 'wipe=s' => \@wipe, 'autoprimary=s' => \@auto, 'order=s' => \@order, ); @@ -56,6 +57,8 @@ while ( my $rec = <> ) { $fieldcache{$hint} = { table => $class->Table, + sequence => $class->Sequence, + pkey => $class->Identity, fields => \@cols, }; } @@ -80,6 +83,7 @@ $output->print("SET CLIENT_ENCODING TO 'UNICODE';\n\n"); for my $h (@order) { my $fields = join(',', @{ $fieldcache{$h}{fields} }); + $output->print( "DELETE FROM $fieldcache{$h}{table};\n" ) if (grep {$_ eq $h } @wipe); $output->print( "COPY $fieldcache{$h}{table} ($fields) FROM STDIN;\n" ); for my $line (@{ $lineset{$h} }) { @@ -105,4 +109,7 @@ for my $h (@order) { } $output->print('\.'."\n\n"); + + $output->print("SELECT setval('$fieldcache{$h}{sequence}'::TEXT, (SELECT MAX($fieldcache{$h}{pkey}) FROM $fieldcache{$h}{table}), TRUE);\n\n") + if (!grep { $_ eq $h} @auto); } diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm b/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm index 1ba0499c89..0e56cc2a25 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm @@ -57,6 +57,7 @@ sub import { $$fieldmap{$n}{hint} = $c; $$fieldmap{$n}{virtual} = ($idl->{$c}{'oils_persist:virtual'} eq 'true') ? 1 : 0; $$fieldmap{$n}{table} = $idl->{$c}{'oils_persist:tablename'}; + $$fieldmap{$n}{sequence} = $idl->{$c}{fields}{'oils_persist:sequence'}; $$fieldmap{$n}{identity} = $idl->{$c}{fields}{'oils_persist:primary'}; for my $f ( keys %{ $idl->{$c}{fields}{field} } ) { @@ -157,6 +158,11 @@ sub Identity { return $$fieldmap{$class_name}{identity}; } +sub Sequence { + my $class_name = shift; + return $$fieldmap{$class_name}{sequence}; +} + sub Table { my $class_name = shift; return $$fieldmap{$class_name}{table}; diff --git a/Open-ILS/src/sql/Pg/800.fkeys.sql b/Open-ILS/src/sql/Pg/800.fkeys.sql index ac93024f2f..e241bf7b48 100644 --- a/Open-ILS/src/sql/Pg/800.fkeys.sql +++ b/Open-ILS/src/sql/Pg/800.fkeys.sql @@ -9,8 +9,8 @@ ALTER TABLE actor.stat_cat ADD CONSTRAINT actor_stat_cat_owner_fkey FOREIGN KEY ALTER TABLE actor.stat_cat_entry ADD CONSTRAINT actor_stat_cat_entry_stat_cat_fkey FOREIGN KEY (stat_cat) REFERENCES actor.stat_cat (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; ALTER TABLE actor.stat_cat_entry ADD CONSTRAINT actor_stat_cat_entry_owner_fkey FOREIGN KEY (owner) REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE actor.stat_cat_entry_usr_map ADD CONSTRAINT actor_sc_tu_fkey FOREIGN KEY (target_usr) REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; - +ALTER TABLE actor.stat_cat_entry_usr_map ADD CONSTRAINT actor_sceum_tu_fkey FOREIGN KEY (target_usr) REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE actor.stat_cat_entry_usr_map ADD CONSTRAINT actor_sceum_sc_fkey FOREIGN KEY (stat_cat) REFERENCES actor.stat_cat (id) DEFERRABLE INITIALLY DEFERRED; ALTER TABLE actor.org_unit ADD CONSTRAINT actor_org_unit_mailing_address_fkey FOREIGN KEY (mailing_address) REFERENCES actor.org_address (id) DEFERRABLE INITIALLY DEFERRED; ALTER TABLE actor.org_unit ADD CONSTRAINT actor_org_unit_billing_address_fkey FOREIGN KEY (billing_address) REFERENCES actor.org_address (id) DEFERRABLE INITIALLY DEFERRED; @@ -67,6 +67,7 @@ ALTER TABLE asset.stat_cat_entry ADD CONSTRAINT a_sce_owner_fkey FOREIGN KEY (ow ALTER TABLE asset.stat_cat_entry_copy_map ADD CONSTRAINT a_sc_oc_fkey FOREIGN KEY (owning_copy) REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; ALTER TABLE asset.stat_cat_entry_copy_map ADD CONSTRAINT a_sc_sce_fkey FOREIGN KEY (stat_cat_entry) REFERENCES asset.stat_cat_entry (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE asset.stat_cat_entry_copy_map ADD CONSTRAINT a_sc_sc_fkey FOREIGN KEY (stat_cat) REFERENCES asset.stat_cat (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; ALTER TABLE money.billable_xact ADD CONSTRAINT money_billable_xact_usr_fkey FOREIGN KEY (usr) REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED; -- 2.43.2