From: Dan Scott Date: Wed, 11 Dec 2019 14:20:48 +0000 (-0500) Subject: LP#1856047: Avoid major upgrade pain with auto_renewal column X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fdbs%2Flp1856047_avoid_hours_of_asset.circulation_updates;p=working%2FEvergreen.git LP#1856047: Avoid major upgrade pain with auto_renewal column If we don't set the auto_renewal column to DEFAULT FALSE NOT NULL from the beginning, then we need to apply updates to all of the circulation rows -- which can take an extremely long time. Setting these attributes from the beginning turns the subsequent upgrade UPDATE statement into a no-op, as none of the rows will be NULL. And the subsequent ALTER COLUMN statement that adds the DEFAULT FALSE NOT NULL attributes runs harmlessly. Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/sql/Pg/upgrade/1123.schema.autorenewals.sql b/Open-ILS/src/sql/Pg/upgrade/1123.schema.autorenewals.sql index e8b5fcfb15..898c1d078b 100644 --- a/Open-ILS/src/sql/Pg/upgrade/1123.schema.autorenewals.sql +++ b/Open-ILS/src/sql/Pg/upgrade/1123.schema.autorenewals.sql @@ -6,13 +6,13 @@ SELECT evergreen.upgrade_deps_block_check('1123', :eg_version); ADD column max_auto_renewals INTEGER; ALTER TABLE action.circulation - ADD column auto_renewal BOOLEAN; + ADD column auto_renewal BOOLEAN DEFAULT FALSE NOT NULL; ALTER TABLE action.circulation ADD column auto_renewal_remaining INTEGER; ALTER TABLE action.aged_circulation - ADD column auto_renewal BOOLEAN; + ADD column auto_renewal BOOLEAN DEFAULT FALSE NOT NULL; ALTER TABLE action.aged_circulation ADD column auto_renewal_remaining INTEGER; diff --git a/Open-ILS/src/sql/Pg/version-upgrade/3.1.5-3.2.0-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/3.1.5-3.2.0-upgrade-db.sql index bc276b0d57..8a9940b914 100644 --- a/Open-ILS/src/sql/Pg/version-upgrade/3.1.5-3.2.0-upgrade-db.sql +++ b/Open-ILS/src/sql/Pg/version-upgrade/3.1.5-3.2.0-upgrade-db.sql @@ -2159,13 +2159,13 @@ SELECT evergreen.upgrade_deps_block_check('1123', :eg_version); ADD column max_auto_renewals INTEGER; ALTER TABLE action.circulation - ADD column auto_renewal BOOLEAN; + ADD column auto_renewal BOOLEAN DEFAULT FALSE NOT NULL; ALTER TABLE action.circulation ADD column auto_renewal_remaining INTEGER; ALTER TABLE action.aged_circulation - ADD column auto_renewal BOOLEAN; + ADD column auto_renewal BOOLEAN DEFAULT FALSE NOT NULL; ALTER TABLE action.aged_circulation ADD column auto_renewal_remaining INTEGER;