From: Jason Stephenson Date: Thu, 29 Aug 2019 15:06:56 +0000 (-0400) Subject: Lp 1839002: Default circulation auto_renewal field to FALSE X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=96c47dc7b8f9392c5d770bd8efff7ab5175495a0;p=evergreen%2Fmasslnc.git Lp 1839002: Default circulation auto_renewal field to FALSE Change the definition of the action.circulation table so that the auto_renewal field is not null, default false. Add an upgrade script to update the field values and alter the field definition in both the action.circulation and action.aged_circulation tables. Signed-off-by: Jason Stephenson Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index e6fe8cd9c4..3fb3b4a782 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -148,7 +148,7 @@ CREATE TABLE action.circulation ( DEFERRABLE INITIALLY DEFERRED, copy_location INT NOT NULL DEFAULT 1 REFERENCES asset.copy_location (id) DEFERRABLE INITIALLY DEFERRED, checkin_scan_time TIMESTAMP WITH TIME ZONE, - auto_renewal BOOLEAN, + auto_renewal BOOLEAN NOT NULL DEFAULT FALSE, auto_renewal_remaining INTEGER ) INHERITS (money.billable_xact); ALTER TABLE action.circulation ADD PRIMARY KEY (id); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.action_circulation-auto_renewal-default-false.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.action_circulation-auto_renewal-default-false.sql new file mode 100644 index 0000000000..e5fc738084 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.action_circulation-auto_renewal-default-false.sql @@ -0,0 +1,20 @@ +BEGIN; + +--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +UPDATE action.circulation SET auto_renewal = FALSE WHERE auto_renewal IS NULL; + +UPDATE action.aged_circulation SET auto_renewal = FALSE WHERE auto_renewal IS NULL; + +COMMIT; + +-- The following two changes cannot occur in a transaction with the +-- above updates because we will get an error about not being able to +-- alter a table with pending transactions. They also need to occur +-- after the above updates or the SET NOT NULL change will fail. + +ALTER TABLE action.circulation ALTER COLUMN auto_renewal SET DEFAULT FALSE; +ALTER TABLE action.circulation ALTER COLUMN auto_renewal SET NOT NULL; + +ALTER TABLE action.aged_circulation ALTER COLUMN auto_renewal SET DEFAULT FALSE; +ALTER TABLE action.aged_circulation ALTER COLUMN auto_renewal SET NOT NULL;