Limit 'state' values to
'new','pending','on-order','received','cancelled'
https://bugs.launchpad.net/evergreen/+bug/893193
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Michael Peters <mrpeters@library.in.gov>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
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,
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);
--- /dev/null
+-- 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;