From 24295f9c2edaed9f8ba5fe93d2dac152c55cda10 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 6 Jul 2010 15:56:17 +0000 Subject: [PATCH] integrate serial.unit by relaxing fkeys against asset.copy and adding hold support git-svn-id: svn://svn.open-ils.org/ILS/trunk@16851 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Storage/CDBI.pm | 22 +++++++++ .../OpenILS/Application/Storage/CDBI/asset.pm | 2 +- .../OpenILS/Application/Storage/CDBI/serial.pm | 50 ++++++++++++++++++++ .../OpenILS/Application/Storage/Driver/Pg/dbi.pm | 28 ++++++++++++ .../Application/Storage/Publisher/action.pm | 11 +++++ .../OpenILS/Application/Storage/Publisher/asset.pm | 53 +++++++++++++++++++++- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/090.schema.action.sql | 12 ++--- Open-ILS/src/sql/Pg/200.schema.acq.sql | 2 +- Open-ILS/src/sql/Pg/800.fkeys.sql | 8 +++- Open-ILS/src/sql/Pg/extend-reporter.sql | 2 +- .../upgrade/0325.schema.generalize-copy-fkeys.sql | 23 ++++++++++ 12 files changed, 202 insertions(+), 13 deletions(-) create mode 100644 Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/serial.pm create mode 100644 Open-ILS/src/sql/Pg/upgrade/0325.schema.generalize-copy-fkeys.sql diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm index fdf915b12..af9cbed37 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm @@ -10,6 +10,7 @@ use OpenILS::Application::Storage::CDBI::actor; use OpenILS::Application::Storage::CDBI::action; use OpenILS::Application::Storage::CDBI::booking; use OpenILS::Application::Storage::CDBI::asset; +use OpenILS::Application::Storage::CDBI::serial; use OpenILS::Application::Storage::CDBI::authority; use OpenILS::Application::Storage::CDBI::biblio; use OpenILS::Application::Storage::CDBI::config; @@ -521,6 +522,25 @@ sub modify_from_fieldmapper { asset::copy->has_a( location => 'asset::copy_location' ); asset::copy->has_a( circ_lib => 'actor::org_unit' ); + serial::unit->has_a( call_number => 'asset::call_number' ); + serial::unit->has_a( creator => 'actor::user' ); + serial::unit->has_a( editor => 'actor::user' ); + serial::unit->has_a( status => 'config::copy_status' ); + serial::unit->has_a( location => 'asset::copy_location' ); + serial::unit->has_a( circ_lib => 'actor::org_unit' ); + + serial::item->has_a( unit => 'serial::unit' ); + serial::item->has_a( issuance => 'serial::issuance' ); + serial::item->has_a( uri => 'asset::uri' ); + + serial::unit->has_many( items => 'serial::item' ); + + serial::issuance->has_a( subscription => 'serial::subsription' ); + serial::issuance->has_many( items => 'serial::item' ); + + serial::subscription->has_a( record_entry => 'biblio::record_entry' ); + serial::subscription->has_many( issuances => 'serial::issuance' ); + asset::call_number_note->has_a( call_number => 'asset::call_number' ); asset::call_number->has_a( record => 'biblio::record_entry' ); @@ -585,6 +605,7 @@ sub modify_from_fieldmapper { action::circulation->has_a( target_copy => 'asset::copy' ); asset::copy->has_many( circulations => 'action::circulation' => 'target_copy' ); + serial::unit->has_many( circulations => 'action::circulation' => 'target_copy' ); booking::reservation->has_a( pickup_lib => 'actor::org_unit' ); @@ -734,6 +755,7 @@ sub modify_from_fieldmapper { action::hold_request->has_many( eligible_copies => [ 'action::hold_copy_map' => 'target_copy' ] ); asset::copy->has_many( holds => [ 'action::hold_copy_map' => 'hold' ] ); + serial::unit->has_many( holds => [ 'action::hold_copy_map' => 'hold' ] ); container::biblio_record_entry_bucket->has_a( owner => 'actor::user' ); container::biblio_record_entry_bucket_item->has_a( bucket => 'container::biblio_record_entry_bucket' ); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm index a93af6820..e2609ea29 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm @@ -44,7 +44,7 @@ use base qw/asset/; __PACKAGE__->table( 'asset_copy' ); __PACKAGE__->columns( Primary => qw/id/ ); __PACKAGE__->columns( Essential => qw/call_number barcode creator create_date editor - edit_date copy_number status loan_duration circ_lib + edit_date copy_number status loan_duration circ_lib dummy_isbn fine_level circulate deposit price ref opac_visible circ_as_type circ_modifier deposit_amount location mint_condition holdable dummy_title dummy_author deleted alert_message diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/serial.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/serial.pm new file mode 100644 index 000000000..3e8f38229 --- /dev/null +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/serial.pm @@ -0,0 +1,50 @@ +package OpenILS::Application::Storage::CDBI::serial; +our $VERSION = 1; + +#------------------------------------------------------------------------------- +package serial; +use base qw/OpenILS::Application::Storage::CDBI/; +#------------------------------------------------------------------------------- +package serial::subscription; +use base qw/serial/; + +__PACKAGE__->table( 'serial_subscription' ); +__PACKAGE__->columns( Primary => qw/id/ ); +__PACKAGE__->columns( Essential => qw/record_entry start_date end_date + expected_date_offset owning_lib/ ); + +#------------------------------------------------------------------------------- +package serial::issuance; +use base qw/serial/; + +__PACKAGE__->table( 'serial_issuance' ); +__PACKAGE__->columns( Primary => qw/id/ ); +__PACKAGE__->columns( Essential => qw/creator editor create_date edit_date + subscription label date_published + holding_code holding_type holding_link_id/ ); + +#------------------------------------------------------------------------------- +package serial::item; +use base qw/serial/; + +__PACKAGE__->table( 'serial_item' ); +__PACKAGE__->columns( Primary => qw/id/ ); +__PACKAGE__->columns( Essential => qw/creator editor create_date edit_date + issuance stream unit uri date_expected + date_received/ ); + +#------------------------------------------------------------------------------- +package serial::unit; +use base qw/serial/; + +__PACKAGE__->table( 'serial_unit' ); +__PACKAGE__->columns( Primary => qw/id/ ); +__PACKAGE__->columns( Essential => qw/call_number barcode creator create_date editor + edit_date copy_number status loan_duration circ_lib + fine_level circulate deposit price ref opac_visible dummy_isbn + circ_as_type circ_modifier deposit_amount location mint_condition + holdable dummy_title dummy_author deleted alert_message label + age_protect floating label_sort_key contents/ ); + +1; + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm index 55b44dae0..0cb4b51e8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm @@ -719,6 +719,34 @@ #------------------------------------------------------------------------------- + package serial::subscription; + + serial::subscription->sequence( 'serial.subscription_id_seq' ); + serial::subscription->table('serial.subscription'); + + #------------------------------------------------------------------------------- + + package serial::issuance; + + serial::issuance->sequence( 'serial.issuance_id_seq' ); + serial::issuance->table('serial.issuance'); + + #------------------------------------------------------------------------------- + + package serial::item; + + serial::item->sequence( 'serial.item_id_seq' ); + serial::item->table('serial.item'); + + #------------------------------------------------------------------------------- + + package serial::unit; + + serial::unit->sequence( 'asset.copy_id_seq' ); + serial::unit->table('serial.unit'); + + #------------------------------------------------------------------------------- + package config::language_map; config::language_map->table('config.language_map'); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm index aee594316..ee47185a5 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -1174,6 +1174,17 @@ sub new_hold_copy_targeter { deleted => 'f' } ) if ($vtree && @{ $vtree->copies }); + } elsif ($hold->hold_type eq 'I') { + my ($itree) = $self + ->method_lookup( 'open-ils.storage.serial.issuance.ranged_tree') + ->run( $hold->target, $hold->selection_ou, $hold->selection_depth ); + + push @$all_copies, + asset::copy->search_where( + { id => [map {$_->unit->id} @{ $itree->items }], + deleted => 'f' } + ) if ($itree && @{ $itree->items }); + } elsif ($hold->hold_type eq 'C' || $hold->hold_type eq 'R' || $hold->hold_type eq 'F') { my $_cp = asset::copy->retrieve($hold->target); push @$all_copies, $_cp if $_cp; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm index 9439aec16..c413085a8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm @@ -781,7 +781,7 @@ sub cn_ranged_tree { next if ($cp->deleted); my $copy = $cp->to_fieldmapper; $copy->status( $cp->status->to_fieldmapper ); - $copy->location( $cp->status->to_fieldmapper ); + $copy->location( $cp->location->to_fieldmapper ); push @{ $call_number->copies }, $copy; } @@ -795,6 +795,57 @@ __PACKAGE__->register_method( api_level => 1, ); + +# XXX Since this is all we need in open-ils.storage for serial stuff ATM, just +# XXX putting it here instead of creating a whole new file. +sub issuance_ranged_tree { + my $self = shift; + my $client = shift; + my $iss = shift; + my $ou = shift; + my $depth = shift || 0; + + my $ou_list = + actor::org_unit + ->db_Main + ->selectcol_arrayref( + 'SELECT id FROM actor.org_unit_descendants(?,?)', + {}, + $ou, + $depth + ); + + return undef unless ($ou_list and @$ou_list); + + $iss = serial::issuance->retrieve( $iss ); + return undef unless ($iss); + + my $issuance = $iss->to_fieldmapper; + $issuance->items([]); + + for my $it ( $iss->items() ) { + my $item = $it->to_fieldmapper; + + next if ($it->unit->deleted); + next unless (grep { $it->unit->circ_lib eq $_ } @$ou_list); + + my $unit = $it->unit->to_fieldmapper; + $unit->status( $it->unit->status->to_fieldmapper ); + $unit->location( $it->unit->location->to_fieldmapper ); + $item->unit( $unit ); + + push @{ $issuance->items }, $item; + } + + return $issuance; +} +__PACKAGE__->register_method( + api_name => 'open-ils.storage.serial.issuance.ranged_tree', + method => 'issuance_ranged_tree', + argc => 1, + api_level => 1, +); + sub merge_record_assets { my $self = shift; my $client = shift; diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 402ac7016..989a07fa3 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -68,7 +68,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0324'); -- berick +INSERT INTO config.upgrade_log (version) VALUES ('0325'); -- miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index 3892e4796..466860b5a 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -23,7 +23,7 @@ CREATE SCHEMA action; CREATE TABLE action.in_house_use ( id SERIAL PRIMARY KEY, - item BIGINT NOT NULL REFERENCES asset.copy (id) DEFERRABLE INITIALLY DEFERRED, + item BIGINT NOT NULL, -- REFERENCES asset.copy (id) DEFERRABLE INITIALLY DEFERRED, -- XXX could be an serial.issuance staff INT NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, org_unit INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, use_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() @@ -349,7 +349,7 @@ CREATE TABLE action.hold_request ( cancel_cause INT REFERENCES action.hold_request_cancel_cause (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED, cancel_note TEXT, target BIGINT NOT NULL, -- see hold_type - current_copy BIGINT REFERENCES asset.copy (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED, + current_copy BIGINT, -- REFERENCES asset.copy (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED, -- XXX could be an serial.unit now... fulfillment_staff INT REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, fulfillment_lib INT REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, request_lib INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, @@ -358,7 +358,7 @@ CREATE TABLE action.hold_request ( selection_ou INT NOT NULL, selection_depth INT NOT NULL DEFAULT 0, pickup_lib INT NOT NULL REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED, - hold_type TEXT NOT NULL CHECK (hold_type IN ('M','T','V','C')), + hold_type TEXT NOT NULL, -- CHECK (hold_type IN ('M','T','V','C')), -- XXX constraint too constraining... holdable_formats TEXT, phone_notify TEXT, email_notify BOOL NOT NULL DEFAULT TRUE, @@ -411,7 +411,7 @@ CREATE INDEX ahn_notify_staff_idx ON action.hold_notification ( notify_staff ); CREATE TABLE action.hold_copy_map ( id SERIAL PRIMARY KEY, hold INT NOT NULL REFERENCES action.hold_request (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, - target_copy BIGINT NOT NULL REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, + target_copy BIGINT NOT NULL, -- REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, -- XXX could be an serial.issuance CONSTRAINT copy_once_per_hold UNIQUE (hold,target_copy) ); -- CREATE INDEX acm_hold_idx ON action.hold_copy_map (hold); @@ -421,7 +421,7 @@ CREATE TABLE action.transit_copy ( id SERIAL PRIMARY KEY, source_send_time TIMESTAMP WITH TIME ZONE, dest_recv_time TIMESTAMP WITH TIME ZONE, - target_copy BIGINT NOT NULL REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, + target_copy BIGINT NOT NULL, -- REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, -- XXX could be an serial.issuance source INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, dest INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, prev_hop INT REFERENCES action.transit_copy (id) DEFERRABLE INITIALLY DEFERRED, @@ -438,7 +438,7 @@ CREATE TABLE action.hold_transit_copy ( hold INT REFERENCES action.hold_request (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED ) INHERITS (action.transit_copy); ALTER TABLE action.hold_transit_copy ADD PRIMARY KEY (id); -ALTER TABLE action.hold_transit_copy ADD CONSTRAINT ahtc_tc_fkey FOREIGN KEY (target_copy) REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; +-- ALTER TABLE action.hold_transit_copy ADD CONSTRAINT ahtc_tc_fkey FOREIGN KEY (target_copy) REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; -- XXX could be an serial.issuance CREATE INDEX active_hold_transit_dest_idx ON "action".hold_transit_copy (dest); CREATE INDEX active_hold_transit_source_idx ON "action".hold_transit_copy (source); CREATE INDEX active_hold_transit_cp_idx ON "action".hold_transit_copy (target_copy); diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql index 814faa26e..34abbc568 100644 --- a/Open-ILS/src/sql/Pg/200.schema.acq.sql +++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql @@ -529,7 +529,7 @@ CREATE TABLE acq.lineitem_detail ( lineitem INT NOT NULL REFERENCES acq.lineitem (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, fund INT REFERENCES acq.fund (id) DEFERRABLE INITIALLY DEFERRED, fund_debit INT REFERENCES acq.fund_debit (id) DEFERRABLE INITIALLY DEFERRED, - eg_copy_id BIGINT REFERENCES asset.copy (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED, + eg_copy_id BIGINT, -- REFERENCES asset.copy (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED, -- XXX could be an serial.issuance barcode TEXT, cn_label TEXT, note TEXT, diff --git a/Open-ILS/src/sql/Pg/800.fkeys.sql b/Open-ILS/src/sql/Pg/800.fkeys.sql index fc05bf5d2..afd2d429b 100644 --- a/Open-ILS/src/sql/Pg/800.fkeys.sql +++ b/Open-ILS/src/sql/Pg/800.fkeys.sql @@ -80,6 +80,10 @@ ALTER TABLE asset.copy ADD CONSTRAINT asset_copy_call_number_fkey FOREIGN KEY (c ALTER TABLE asset.copy ADD CONSTRAINT asset_copy_creator_fkey FOREIGN KEY (creator) REFERENCES actor.usr (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; ALTER TABLE asset.copy ADD CONSTRAINT asset_copy_editor_fkey FOREIGN KEY (editor) REFERENCES actor.usr (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE serial.unit ADD CONSTRAINT serial_unit_call_number_fkey FOREIGN KEY (call_number) REFERENCES asset.call_number (id) DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE serial.unit ADD CONSTRAINT serial_unit_creator_fkey FOREIGN KEY (creator) REFERENCES actor.usr (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE serial.unit ADD CONSTRAINT serial_unit_editor_fkey FOREIGN KEY (editor) REFERENCES actor.usr (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; + ALTER TABLE asset.copy_note ADD CONSTRAINT asset_copy_note_copy_fkey FOREIGN KEY (owning_copy) REFERENCES asset.copy (id) DEFERRABLE INITIALLY DEFERRED; ALTER TABLE asset.copy_note ADD CONSTRAINT asset_copy_note_creator_fkey FOREIGN KEY (creator) REFERENCES actor.usr (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; @@ -96,7 +100,7 @@ ALTER TABLE asset.stat_cat ADD CONSTRAINT a_sc_owner_fkey FOREIGN KEY (owner) RE ALTER TABLE asset.stat_cat_entry ADD CONSTRAINT a_sce_sc_fkey FOREIGN KEY (stat_cat) REFERENCES asset.stat_cat (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; ALTER TABLE asset.stat_cat_entry ADD CONSTRAINT a_sce_owner_fkey FOREIGN KEY (owner) REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; -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_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; @@ -104,7 +108,7 @@ ALTER TABLE money.billable_xact ADD CONSTRAINT money_billable_xact_usr_fkey FORE ALTER TABLE action.circulation ADD CONSTRAINT action_circulation_usr_fkey FOREIGN KEY (usr) REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED; ALTER TABLE action.circulation ADD CONSTRAINT action_circulation_circ_lib_fkey FOREIGN KEY (circ_lib) REFERENCES actor.org_unit (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE action.circulation ADD CONSTRAINT action_circulation_target_copy_fkey FOREIGN KEY (target_copy) REFERENCES asset.copy (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; +-- ALTER TABLE action.circulation ADD CONSTRAINT action_circulation_target_copy_fkey FOREIGN KEY (target_copy) REFERENCES asset.copy (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; ALTER TABLE config.billing_type ADD CONSTRAINT config_billing_type_owner_fkey FOREIGN KEY (owner) REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; diff --git a/Open-ILS/src/sql/Pg/extend-reporter.sql b/Open-ILS/src/sql/Pg/extend-reporter.sql index ded54c873..6a135682b 100644 --- a/Open-ILS/src/sql/Pg/extend-reporter.sql +++ b/Open-ILS/src/sql/Pg/extend-reporter.sql @@ -21,7 +21,7 @@ BEGIN; CREATE SCHEMA extend_reporter; CREATE TABLE extend_reporter.legacy_circ_count ( - id BIGINT PRIMARY KEY REFERENCES asset.copy (id) DEFERRABLE INITIALLY DEFERRED, + id BIGINT PRIMARY KEY, -- REFERENCES asset.copy (id) DEFERRABLE INITIALLY DEFERRED, -- XXX could be an serial.issuance circ_count INT NOT NULL DEFAULT 0 ); diff --git a/Open-ILS/src/sql/Pg/upgrade/0325.schema.generalize-copy-fkeys.sql b/Open-ILS/src/sql/Pg/upgrade/0325.schema.generalize-copy-fkeys.sql new file mode 100644 index 000000000..1c6ea860b --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0325.schema.generalize-copy-fkeys.sql @@ -0,0 +1,23 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0325'); + +ALTER TABLE serial.unit ADD CONSTRAINT serial_unit_call_number_fkey FOREIGN KEY (call_number) REFERENCES asset.call_number (id) DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE serial.unit ADD CONSTRAINT serial_unit_creator_fkey FOREIGN KEY (creator) REFERENCES actor.usr (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE serial.unit ADD CONSTRAINT serial_unit_editor_fkey FOREIGN KEY (editor) REFERENCES actor.usr (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE action.in_house_use DROP CONSTRAINT in_house_use_item_fkey; +ALTER TABLE action.circulation DROP CONSTRAINT action_circulation_target_copy_fkey; +ALTER TABLE action.hold_request DROP CONSTRAINT hold_request_current_copy_fkey; +ALTER TABLE action.hold_request DROP CONSTRAINT hold_request_hold_type_check; +ALTER TABLE action.transit_copy DROP CONSTRAINT transit_copy_target_copy_fkey; +ALTER TABLE action.hold_transit_copy DROP CONSTRAINT ahtc_tc_fkey; + +ALTER TABLE asset.stat_cat_entry_copy_map DROP CONSTRAINT a_sc_oc_fkey; +ALTER TABLE acq.lineitem_detail DROP CONSTRAINT lineitem_detail_eg_copy_id_fkey; + +COMMIT; + +-- This is optional, might fail, that's ok +ALTER TABLE extend_reporter.legacy_circ_count DROP CONSTRAINT legacy_circ_count_id_fkey; + -- 2.11.0