[open-ils-commits] r16851 - in trunk/Open-ILS/src: perlmods/OpenILS/Application/Storage perlmods/OpenILS/Application/Storage/CDBI perlmods/OpenILS/Application/Storage/Driver/Pg perlmods/OpenILS/Application/Storage/Publisher sql/Pg sql/Pg/upgrade (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jul 6 11:56:20 EDT 2010


Author: miker
Date: 2010-07-06 11:56:17 -0400 (Tue, 06 Jul 2010)
New Revision: 16851

Added:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/serial.pm
   trunk/Open-ILS/src/sql/Pg/upgrade/0325.schema.generalize-copy-fkeys.sql
Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
   trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
   trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
   trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql
   trunk/Open-ILS/src/sql/Pg/800.fkeys.sql
   trunk/Open-ILS/src/sql/Pg/extend-reporter.sql
Log:
integrate serial.unit by relaxing fkeys against asset.copy and adding hold support

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm	2010-07-06 15:56:17 UTC (rev 16851)
@@ -44,7 +44,7 @@
 __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

Added: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/serial.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/serial.pm	                        (rev 0)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/serial.pm	2010-07-06 15:56:17 UTC (rev 16851)
@@ -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;
+

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm	2010-07-06 15:56:17 UTC (rev 16851)
@@ -10,6 +10,7 @@
 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 @@
 	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 @@
 
 	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 @@
 	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' );

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm	2010-07-06 15:56:17 UTC (rev 16851)
@@ -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');
 

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2010-07-06 15:56:17 UTC (rev 16851)
@@ -1174,6 +1174,17 @@
 						  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;

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm	2010-07-06 15:56:17 UTC (rev 16851)
@@ -781,7 +781,7 @@
 		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 @@
 	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;

Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-07-06 15:56:17 UTC (rev 16851)
@@ -68,7 +68,7 @@
     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,

Modified: trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/090.schema.action.sql	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/sql/Pg/090.schema.action.sql	2010-07-06 15:56:17 UTC (rev 16851)
@@ -23,7 +23,7 @@
 
 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 @@
 	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 @@
 	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 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 @@
 	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 @@
 	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);

Modified: trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql	2010-07-06 15:56:17 UTC (rev 16851)
@@ -529,7 +529,7 @@
     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,

Modified: trunk/Open-ILS/src/sql/Pg/800.fkeys.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/800.fkeys.sql	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/sql/Pg/800.fkeys.sql	2010-07-06 15:56:17 UTC (rev 16851)
@@ -80,6 +80,10 @@
 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_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 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;
 

Modified: trunk/Open-ILS/src/sql/Pg/extend-reporter.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/extend-reporter.sql	2010-07-06 15:51:31 UTC (rev 16850)
+++ trunk/Open-ILS/src/sql/Pg/extend-reporter.sql	2010-07-06 15:56:17 UTC (rev 16851)
@@ -21,7 +21,7 @@
 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
 );
 

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0325.schema.generalize-copy-fkeys.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0325.schema.generalize-copy-fkeys.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0325.schema.generalize-copy-fkeys.sql	2010-07-06 15:56:17 UTC (rev 16851)
@@ -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;
+



More information about the open-ils-commits mailing list