From 632401a6ee6c4eac311b2f2c400ac052bf988485 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Wed, 11 Dec 2019 09:20:48 -0500 Subject: [PATCH] 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 --- Open-ILS/src/sql/Pg/upgrade/1123.schema.autorenewals.sql | 4 ++-- Open-ILS/src/sql/Pg/version-upgrade/3.1.5-3.2.0-upgrade-db.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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; -- 2.11.0