[open-ils-commits] r19191 - in branches/rel_2_0/Open-ILS/src/sql/Pg: . upgrade (dbwells)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jan 18 13:15:33 EST 2011
Author: dbwells
Date: 2011-01-18 13:15:29 -0500 (Tue, 18 Jan 2011)
New Revision: 19191
Added:
branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0475.schema.auto-placeholder-barcodes.sql
Modified:
branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
branches/rel_2_0/Open-ILS/src/sql/Pg/040.schema.asset.sql
branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
Log:
Auto-generation of placeholder barcodes approved for backport
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2011-01-18 18:06:00 UTC (rev 19190)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2011-01-18 18:15:29 UTC (rev 19191)
@@ -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: branches/rel_2_0/Open-ILS/src/sql/Pg/040.schema.asset.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/040.schema.asset.sql 2011-01-18 18:06:00 UTC (rev 19190)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/040.schema.asset.sql 2011-01-18 18:15:29 UTC (rev 19191)
@@ -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;
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql 2011-01-18 18:06:00 UTC (rev 19190)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql 2011-01-18 18:15:29 UTC (rev 19191)
@@ -31,7 +31,7 @@
-- Highest-numbered individual upgrade script incorporated herein:
-INSERT INTO config.upgrade_log (version) VALUES ('0474');
+INSERT INTO config.upgrade_log (version) VALUES ('0475');
-- Push the auri sequence in case it's out of date
-- Add 2 as the sequence value must be 1 or higher, and seed is -1
@@ -19019,6 +19019,20 @@
SELECT 1 FROM acq.lineitem_marc_attr_definition WHERE code = 'upc'
);
+-- '@@' auto-placeholder barcode support
+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;
-- Some operations go outside of the transaction, because they may
Copied: branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0475.schema.auto-placeholder-barcodes.sql (from rev 19189, trunk/Open-ILS/src/sql/Pg/upgrade/0475.schema.auto-placeholder-barcodes.sql)
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0475.schema.auto-placeholder-barcodes.sql (rev 0)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0475.schema.auto-placeholder-barcodes.sql 2011-01-18 18:15:29 UTC (rev 19191)
@@ -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