From: dbs Date: Wed, 2 Feb 2011 03:28:33 +0000 (+0000) Subject: Apply autogenerate barcode trigger to serial.unit to enable serial checkin X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7e6c22c27afaede81b504ea1310ab17c815f9012;p=evergreen%2Fbjwebb.git 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@19359 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index a8a934700..b0c37b8f9 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -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, diff --git a/Open-ILS/src/sql/Pg/210.schema.serials.sql b/Open-ILS/src/sql/Pg/210.schema.serials.sql index a7fda127b..44ea16918 100644 --- a/Open-ILS/src/sql/Pg/210.schema.serials.sql +++ b/Open-ILS/src/sql/Pg/210.schema.serials.sql @@ -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 index 000000000..ad6b9742d --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0481.schema.serial_unit_generate_barcode_trigger.sql @@ -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;