From: Galen Charlton Date: Fri, 16 Apr 2021 20:59:51 +0000 (-0400) Subject: LP#1904244: schema: make fund.code NOT NULL X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4c3a96cf96a0d638035092d248e2f50eef6eaf4b;p=Evergreen.git LP#1904244: schema: make fund.code NOT NULL Any funds whose code was null will have it set to "FUND-WITH-ID-$id" Signed-off-by: Galen Charlton Signed-off-by: Ruth Frasur Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql index 87c0a50d42..0cfb6089dc 100644 --- a/Open-ILS/src/sql/Pg/200.schema.acq.sql +++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql @@ -214,7 +214,7 @@ CREATE TABLE acq.fund ( name TEXT NOT NULL, year INT NOT NULL DEFAULT EXTRACT( YEAR FROM NOW() ), currency_type TEXT NOT NULL REFERENCES acq.currency_type (code) DEFERRABLE INITIALLY DEFERRED, - code TEXT, + code TEXT NOT NULL, rollover BOOL NOT NULL DEFAULT FALSE, propagate BOOL NOT NULL DEFAULT TRUE, active BOOL NOT NULL DEFAULT TRUE, diff --git a/Open-ILS/src/sql/Pg/upgrade/ZZZZ.schema.make-acqf-code-not-null.sql b/Open-ILS/src/sql/Pg/upgrade/ZZZZ.schema.make-acqf-code-not-null.sql new file mode 100644 index 0000000000..f923c1131e --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/ZZZZ.schema.make-acqf-code-not-null.sql @@ -0,0 +1,11 @@ +BEGIN; + +-- if there are any straggling funds without a code set, fix that +UPDATE acq.fund +SET code = 'FUND-WITH-ID-' || id +WHERE code IS NULL; + +ALTER TABLE acq.fund + ALTER COLUMN code SET NOT NULL; + +COMMIT;