[open-ils-commits] r14502 - 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
Mon Oct 19 22:36:13 EDT 2009
Author: scottmk
Date: 2009-10-19 22:36:11 -0400 (Mon, 19 Oct 2009)
New Revision: 14502
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0039.schema.acp_status_date_changed.sql
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
Log:
Add new column status_changed_time to asset.copy,
with a trigger to maintain it.
Add corresponding new column to auditor.asset_copy_history.
M Open-ILS/src/sql/Pg/002.schema.config.sql
A Open-ILS/src/sql/Pg/upgrade/0039.schema.acp_status_date_changed.sql
M Open-ILS/examples/fm_IDL.xml
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2009-10-20 00:21:09 UTC (rev 14501)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2009-10-20 02:36:11 UTC (rev 14502)
@@ -3290,6 +3290,7 @@
<field reporter:label="Price" name="price" reporter:datatype="money" />
<field reporter:label="Is Reference" name="ref" reporter:datatype="bool"/>
<field reporter:label="Copy Status" name="status" reporter:datatype="link"/>
+ <field reporter:label="Copy Status Changed Time" name="status_changed_time" reporter:datatype="timestamp"/>
<field reporter:label="Copy Notes" name="notes" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Stat-Cat entry maps" name="stat_cat_entry_copy_maps" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Circulations" name="circulations" oils_persist:virtual="true" reporter:datatype="link"/>
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-10-20 00:21:09 UTC (rev 14501)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-10-20 02:36:11 UTC (rev 14502)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0038'); -- senator
+INSERT INTO config.upgrade_log (version) VALUES ('0039'); -- mck9
CREATE TABLE config.bib_source (
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0039.schema.acp_status_date_changed.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0039.schema.acp_status_date_changed.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0039.schema.acp_status_date_changed.sql 2009-10-20 02:36:11 UTC (rev 14502)
@@ -0,0 +1,28 @@
+BEGIN;
+
+-- Add new column status_changed_date to asset.copy, with trigger to maintain it
+-- Add corresponding new column to auditor.asset_copy_history
+
+INSERT INTO config.upgrade_log (version) VALUES ('0039'); -- mck9
+
+ALTER TABLE asset.copy
+ ADD COLUMN status_changed_time TIMESTAMPTZ;
+
+ALTER TABLE auditor.asset_copy_history
+ ADD COLUMN status_changed_time TIMESTAMPTZ;
+
+CREATE OR REPLACE FUNCTION asset.acp_status_changed()
+RETURNS TRIGGER AS $$
+BEGIN
+ IF NEW.status <> OLD.status THEN
+ NEW.status_changed_time := now();
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+CREATE TRIGGER acp_status_changed_trig
+ BEFORE UPDATE ON asset.copy
+ FOR EACH ROW EXECUTE PROCEDURE asset.acp_status_changed();
+
+COMMIT;
More information about the open-ils-commits
mailing list