[open-ils-commits] r19189 - in trunk/Open-ILS/src/sql/Pg: . upgrade (dbwells)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jan 17 18:34:56 EST 2011
Author: dbwells
Date: 2011-01-17 18:34:49 -0500 (Mon, 17 Jan 2011)
New Revision: 19189
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0475.schema.auto-placeholder-barcodes.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/040.schema.asset.sql
Log:
Auto-generation of placeholder barcodes
This commit implements a very basic trigger for auto-generating placeholder barcodes, as discussed at the Dec. 14 2010 IRC developer meeting. The 1.6.1-2.0 upgrade script has not been changed, as backporting this to 2.0 is pending review.
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2011-01-17 19:30:19 UTC (rev 19188)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2011-01-17 23:34:49 UTC (rev 19189)
@@ -70,7 +70,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0474'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0475'); -- dbwells
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/040.schema.asset.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/040.schema.asset.sql 2011-01-17 19:30:19 UTC (rev 19188)
+++ trunk/Open-ILS/src/sql/Pg/040.schema.asset.sql 2011-01-17 23:34:49 UTC (rev 19189)
@@ -682,5 +682,18 @@
END;
$f$ LANGUAGE PLPGSQL;
+CREATE OR REPLACE FUNCTION asset.autogenerate_placeholder_barcode ( ) RETURNS TRIGGER AS $f$
+BEGIN
+ IF NEW.barcode LIKE '@@%' THEN
+ NEW.barcode := '@@' || NEW.id;
+ END IF;
+ RETURN NEW;
+END;
+$f$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER autogenerate_placeholder_barcode
+ BEFORE INSERT OR UPDATE ON asset.copy
+ FOR EACH ROW EXECUTE PROCEDURE asset.autogenerate_placeholder_barcode();
+
COMMIT;
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0475.schema.auto-placeholder-barcodes.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0475.schema.auto-placeholder-barcodes.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0475.schema.auto-placeholder-barcodes.sql 2011-01-17 23:34:49 UTC (rev 19189)
@@ -0,0 +1,18 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0475'); -- dbwells
+
+CREATE OR REPLACE FUNCTION asset.autogenerate_placeholder_barcode ( ) RETURNS TRIGGER AS $f$
+BEGIN
+ IF NEW.barcode LIKE '@@%' THEN
+ NEW.barcode := '@@' || NEW.id;
+ END IF;
+ RETURN NEW;
+END;
+$f$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER autogenerate_placeholder_barcode
+ BEFORE INSERT OR UPDATE ON asset.copy
+ FOR EACH ROW EXECUTE PROCEDURE asset.autogenerate_placeholder_barcode();
+
+COMMIT;
More information about the open-ils-commits
mailing list