[open-ils-commits] r19359 - in trunk/Open-ILS/src/sql/Pg: . upgrade (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Feb 1 22:28:35 EST 2011


Author: dbs
Date: 2011-02-01 22:28:33 -0500 (Tue, 01 Feb 2011)
New Revision: 19359

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0481.schema.serial_unit_generate_barcode_trigger.sql
Modified:
   trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
   trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql
Log:
Apply autogenerate barcode trigger to serial.unit to enable serial checkin

Serial checkin tried to use the '@@AUTO' macro to autogenerate barcodes,
but unfortunately the required trigger had only been defined on the parent
table asset.copy and not on the child table serial.unit. Here we define the
trigger on serial.unit to resolve that problem.


Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2011-02-01 23:40:24 UTC (rev 19358)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2011-02-02 03:28:33 UTC (rev 19359)
@@ -70,7 +70,7 @@
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0480'); -- phasefx
+INSERT INTO config.upgrade_log (version) VALUES ('0481'); -- dbs
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,

Modified: trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql	2011-02-01 23:40:24 UTC (rev 19358)
+++ trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql	2011-02-02 03:28:33 UTC (rev 19359)
@@ -219,6 +219,12 @@
 -- must create this rule explicitly; it is not inherited from asset.copy
 CREATE RULE protect_serial_unit_delete AS ON DELETE TO serial.unit DO INSTEAD UPDATE serial.unit SET deleted = TRUE WHERE OLD.id = serial.unit.id;
 
+-- must create this trigger explicitly; it is not inherited from asset.copy
+CREATE TRIGGER autogenerate_placeholder_barcode
+   BEFORE INSERT OR UPDATE ON serial.unit 
+   FOR EACH ROW EXECUTE PROCEDURE asset.autogenerate_placeholder_barcode()
+;
+
 CREATE TABLE serial.item (
 	id              SERIAL  PRIMARY KEY,
 	creator         INT     NOT NULL

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0481.schema.serial_unit_generate_barcode_trigger.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0481.schema.serial_unit_generate_barcode_trigger.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0481.schema.serial_unit_generate_barcode_trigger.sql	2011-02-02 03:28:33 UTC (rev 19359)
@@ -0,0 +1,12 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log(version) VALUES ('0481'); -- dbs
+
+-- We defined the same trigger on the parent table asset.copy
+-- but we need to define it on child tables explicitly as well
+CREATE TRIGGER autogenerate_placeholder_barcode
+   BEFORE INSERT OR UPDATE ON serial.unit 
+   FOR EACH ROW EXECUTE PROCEDURE asset.autogenerate_placeholder_barcode()
+;
+
+COMMIT;



More information about the open-ils-commits mailing list