[open-ils-commits] r14087 - in trunk/Open-ILS: examples src/sql/Pg src/sql/Pg/upgrade (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Sep 22 13:17:20 EDT 2009
Author: scottmk
Date: 2009-09-22 13:17:16 -0400 (Tue, 22 Sep 2009)
New Revision: 14087
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0012.schema.circ-parent-circ.sql
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
trunk/Open-ILS/src/sql/Pg/upgrade/0011.schema.circ-checkin-ws-and-scan-time.sql
Log:
1. Add new column parent_circ to action.circulation, to connect
renewals to the original circulations (or to previous renewals).
2. Add a pesky semicolon to a previous upgrade script.
M Open-ILS/src/sql/Pg/090.schema.action.sql
A Open-ILS/src/sql/Pg/upgrade/0012.schema.circ-parent-circ.sql
M Open-ILS/src/sql/Pg/upgrade/0011.schema.circ-checkin-ws-and-scan-time.sql
M Open-ILS/examples/fm_IDL.xml
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2009-09-22 17:03:13 UTC (rev 14086)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2009-09-22 17:17:16 UTC (rev 14087)
@@ -2078,6 +2078,7 @@
<field reporter:label="Workstation" name="workstation" reporter:datatype="link"/>
<field reporter:label="Checkin Workstation" name="checkin_workstation" reporter:datatype="link"/>
<field reporter:label="Checkin Scan Date/Time" name="checkin_scan_time" reporter:datatype="timestamp" />
+ <field reporter:label="Parent Circulation" name="parent_circ" reporter:datatype="link"/>
<field reporter:label="Transaction Billings" name="billings" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Transaction Payments" name="payments" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Base Transaction" name="billable_transaction" oils_persist:virtual="true" reporter:datatype="link"/>
@@ -2103,6 +2104,8 @@
<link field="payment_total" reltype="might_have" key="xact" map="" class="rxpt"/>
<link field="workstation" reltype="has_a" key="id" map="" class="aws"/>
<link field="checkin_workstation" reltype="has_a" key="id" map="" class="aws"/>
+ <link field="parent_circ" reltype="might_have" key="id" map="" class="circ"/>
+ <link field="renewals" reltype="has_many" key="parent_circ" map="" class="circ"/>
</links>
</class>
<class id="combcirc" controller="open-ils.cstore" oils_obj:fieldmapper="action::all_circulation" oils_persist:tablename="action.all_circulation" reporter:core="true" reporter:label="Combined Aged and Active Circulations" oils_persist:readonly="true">
Modified: trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/090.schema.action.sql 2009-09-22 17:03:13 UTC (rev 14086)
+++ trunk/Open-ILS/src/sql/Pg/090.schema.action.sql 2009-09-22 17:17:16 UTC (rev 14087)
@@ -133,6 +133,10 @@
checkin_scan_time TIMESTAMP WITH TIME ZONE
) INHERITS (money.billable_xact);
ALTER TABLE action.circulation ADD PRIMARY KEY (id);
+ALTER TABLE action.circulation
+ ADD COLUMN parent_circ BIGINT
+ REFERENCES action.circulation( id )
+ DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX circ_open_xacts_idx ON action.circulation (usr) WHERE xact_finish IS NULL;
CREATE INDEX circ_outstanding_idx ON action.circulation (usr) WHERE checkin_time IS NULL;
CREATE INDEX circ_checkin_time ON "action".circulation (checkin_time) WHERE checkin_time IS NOT NULL;
@@ -141,7 +145,9 @@
CREATE INDEX circ_all_usr_idx ON action.circulation ( usr );
CREATE INDEX circ_circ_staff_idx ON action.circulation ( circ_staff );
CREATE INDEX circ_checkin_staff_idx ON action.circulation ( checkin_staff );
+CREATE UNIQUE INDEX circ_parent_idx ON action.circulation ( parent_circ ) WHERE parent_circ IS NOT NULL;
+
CREATE TRIGGER mat_summary_create_tgr AFTER INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_create ();
CREATE TRIGGER mat_summary_change_tgr AFTER UPDATE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_update ();
CREATE TRIGGER mat_summary_remove_tgr AFTER DELETE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_delete ();
@@ -198,14 +204,14 @@
circ_lib, circ_staff, checkin_staff, checkin_lib, renewal_remaining, due_date,
stop_fines_time, checkin_time, create_time, duration, fine_interval, recuring_fine,
max_fine, phone_renewal, desk_renewal, opac_renewal, duration_rule, recuring_fine_rule,
- max_fine_rule, stop_fines)
+ max_fine_rule, stop_fines, checkin_workstation, checkin_scan_time, parent_circ)
SELECT
id,usr_post_code, usr_home_ou, usr_profile, usr_birth_year, copy_call_number, copy_location,
copy_owning_lib, copy_circ_lib, copy_bib_record, xact_start, xact_finish, target_copy,
circ_lib, circ_staff, checkin_staff, checkin_lib, renewal_remaining, due_date,
stop_fines_time, checkin_time, create_time, duration, fine_interval, recuring_fine,
max_fine, phone_renewal, desk_renewal, opac_renewal, duration_rule, recuring_fine_rule,
- max_fine_rule, stop_fines
+ max_fine_rule, stop_fines, checkin_workstation, checkin_scan_time, parent_circ
FROM action.all_circulation WHERE id = OLD.id;
RETURN OLD;
Modified: trunk/Open-ILS/src/sql/Pg/upgrade/0011.schema.circ-checkin-ws-and-scan-time.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0011.schema.circ-checkin-ws-and-scan-time.sql 2009-09-22 17:03:13 UTC (rev 14086)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0011.schema.circ-checkin-ws-and-scan-time.sql 2009-09-22 17:17:16 UTC (rev 14087)
@@ -1,4 +1,4 @@
-BEGIN
+BEGIN;
INSERT INTO config.upgrade_log (version) VALUES ('0011.schema.circ-checkin-ws-and-scan-time.sql');
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0012.schema.circ-parent-circ.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0012.schema.circ-parent-circ.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0012.schema.circ-parent-circ.sql 2009-09-22 17:17:16 UTC (rev 14087)
@@ -0,0 +1,36 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0012.schema.circ-parent-circ.sql');
+
+ALTER TABLE action.circulation
+ADD COLUMN parent_circ BIGINT
+ REFERENCES action.circulation(id)
+ DEFERRABLE INITIALLY DEFERRED;
+
+CREATE UNIQUE INDEX circ_parent_idx
+ON action.circulation( parent_circ )
+WHERE parent_circ IS NOT NULL;
+
+CREATE OR REPLACE FUNCTION action.age_circ_on_delete () RETURNS TRIGGER AS $$
+BEGIN
+ INSERT INTO action.aged_circulation
+ (id,usr_post_code, usr_home_ou, usr_profile, usr_birth_year, copy_call_number, copy_location,
+ copy_owning_lib, copy_circ_lib, copy_bib_record, xact_start, xact_finish, target_copy,
+ circ_lib, circ_staff, checkin_staff, checkin_lib, renewal_remaining, due_date,
+ stop_fines_time, checkin_time, create_time, duration, fine_interval, recuring_fine,
+ max_fine, phone_renewal, desk_renewal, opac_renewal, duration_rule, recuring_fine_rule,
+ max_fine_rule, stop_fines, checkin_workstation, checkin_scan_time, parent_circ)
+ SELECT
+ id,usr_post_code, usr_home_ou, usr_profile, usr_birth_year, copy_call_number, copy_location,
+ copy_owning_lib, copy_circ_lib, copy_bib_record, xact_start, xact_finish, target_copy,
+ circ_lib, circ_staff, checkin_staff, checkin_lib, renewal_remaining, due_date,
+ stop_fines_time, checkin_time, create_time, duration, fine_interval, recuring_fine,
+ max_fine, phone_renewal, desk_renewal, opac_renewal, duration_rule, recuring_fine_rule,
+ max_fine_rule, stop_fines, checkin_workstation, checkin_scan_time, parent_circ
+ FROM action.all_circulation WHERE id = OLD.id;
+
+ RETURN OLD;
+END;
+$$ LANGUAGE 'plpgsql';
+
+COMMIT;
More information about the open-ils-commits
mailing list