Apply autogenerate barcode trigger to serial.unit to enable serial checkin
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 2 Feb 2011 03:28:33 +0000 (03:28 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 2 Feb 2011 03:28:33 +0000 (03:28 +0000)
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.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19359 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/210.schema.serials.sql
Open-ILS/src/sql/Pg/upgrade/0481.schema.serial_unit_generate_barcode_trigger.sql [new file with mode: 0644]

index a8a9347..b0c37b8 100644 (file)
@@ -70,7 +70,7 @@ CREATE TABLE config.upgrade_log (
     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,
index a7fda12..44ea169 100644 (file)
@@ -219,6 +219,12 @@ CREATE INDEX unit_editor_idx   ON serial.unit ( editor );
 -- 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
diff --git a/Open-ILS/src/sql/Pg/upgrade/0481.schema.serial_unit_generate_barcode_trigger.sql b/Open-ILS/src/sql/Pg/upgrade/0481.schema.serial_unit_generate_barcode_trigger.sql
new file mode 100644 (file)
index 0000000..ad6b974
--- /dev/null
@@ -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;