From: Bill Erickson Date: Wed, 23 Nov 2011 15:54:51 +0000 (-0500) Subject: Add constraint to ACQ PO state value X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9390b25f1904ff01093409ff8f29f49b6a2f1289;p=evergreen%2Fpines.git Add constraint to ACQ PO state value Limit 'state' values to 'new','pending','on-order','received','cancelled' https://bugs.launchpad.net/evergreen/+bug/893193 Signed-off-by: Bill Erickson Signed-off-by: Michael Peters Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index bfcc2192c6..258aa50673 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -87,7 +87,7 @@ CREATE TRIGGER no_overlapping_deps BEFORE INSERT OR UPDATE ON config.db_patch_dependencies FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates'); -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0721', :eg_version); -- berick/miker +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0722', :eg_version); -- berick/mrpeters/senator CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql index 10e29ef9e0..f4669b90f6 100644 --- a/Open-ILS/src/sql/Pg/200.schema.acq.sql +++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql @@ -379,7 +379,8 @@ CREATE TABLE acq.purchase_order ( name TEXT NOT NULL, cancel_reason INT REFERENCES acq.cancel_reason( id ) DEFERRABLE INITIALLY DEFERRED, - prepayment_required BOOLEAN NOT NULL DEFAULT FALSE + prepayment_required BOOLEAN NOT NULL DEFAULT FALSE, + CONSTRAINT valid_po_state CHECK (state IN ('new','pending','on-order','received','cancelled')) ); CREATE INDEX po_owner_idx ON acq.purchase_order (owner); CREATE INDEX po_provider_idx ON acq.purchase_order (provider); diff --git a/Open-ILS/src/sql/Pg/upgrade/0722.schema.acq-po-state-constraint.sql b/Open-ILS/src/sql/Pg/upgrade/0722.schema.acq-po-state-constraint.sql new file mode 100644 index 0000000000..589610e95b --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0722.schema.acq-po-state-constraint.sql @@ -0,0 +1,12 @@ +-- Evergreen DB patch 0722.schema.acq-po-state-constraint.sql +-- +BEGIN; + + +-- check whether patch can be applied +SELECT evergreen.upgrade_deps_block_check('0722', :eg_version); + +ALTER TABLE acq.purchase_order ADD CONSTRAINT valid_po_state + CHECK (state IN ('new','pending','on-order','received','cancelled')); + +COMMIT;