LP#1856047: Avoid major upgrade pain with auto_renewal column user/dbs/avoid_hours_of_asset.circulation_updates user/dbs/lp1856047_avoid_hours_of_asset.circulation_updates
authorDan Scott <dan@coffeecode.net>
Wed, 11 Dec 2019 14:20:48 +0000 (09:20 -0500)
committerDan Scott <dan@coffeecode.net>
Wed, 11 Dec 2019 14:45:47 +0000 (09:45 -0500)
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 <dan@coffeecode.net>
Open-ILS/src/sql/Pg/upgrade/1123.schema.autorenewals.sql
Open-ILS/src/sql/Pg/version-upgrade/3.1.5-3.2.0-upgrade-db.sql

index e8b5fcf..898c1d0 100644 (file)
@@ -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;
index bc276b0..8a9940b 100644 (file)
@@ -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;