JBAS-1525 Holds purge settings and cron script
authorBill Erickson <berickxx@gmail.com>
Wed, 21 Sep 2016 16:10:48 +0000 (12:10 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/purge-holds.sql [new file with mode: 0644]
KCLS/sql/schema/revert/purge-holds.sql [new file with mode: 0644]
KCLS/sql/schema/sqitch.plan
KCLS/sql/schema/verify/purge-holds.sql [new file with mode: 0644]
KCLS/utility-scripts/CRONTAB
KCLS/utility-scripts/purge_holds/purge_holds.sh [new file with mode: 0755]

diff --git a/KCLS/sql/schema/deploy/purge-holds.sql b/KCLS/sql/schema/deploy/purge-holds.sql
new file mode 100644 (file)
index 0000000..1a4b254
--- /dev/null
@@ -0,0 +1,13 @@
+-- Deploy kcls-evergreen:purge-holds to pg
+-- requires: audit-table-maint
+
+BEGIN;
+
+
+-- Start by purging really old holds. 
+-- The age will march forward as we work through batches.
+UPDATE config.global_flag 
+    SET enabled = TRUE, value = '5 years' 
+    WHERE name ~ 'history.hold.retention_age';
+
+COMMIT;
diff --git a/KCLS/sql/schema/revert/purge-holds.sql b/KCLS/sql/schema/revert/purge-holds.sql
new file mode 100644 (file)
index 0000000..ff58d8a
--- /dev/null
@@ -0,0 +1,7 @@
+-- Revert kcls-evergreen:purge-holds from pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
index 4257c8a..bf93f16 100644 (file)
@@ -38,5 +38,6 @@ self-reg-net-access-level [purge-user-activity] 2016-05-25T14:59:56Z Bill Ericks
 vand-delete-speed-indexes [self-reg-net-access-level] 2016-09-30T14:52:21Z Bill Erickson <berickxx@gmail.com> # Indexes to speed up vandelay queue deleting
 auth-prop-mods-bib-meta [ingram-edi-mods] 2016-06-13T16:07:28Z Bill Erickson <berickxx@gmail.com> # Authority propagation udpates bib editor/edit_date
 backstage-exports-continued [ingram-edi-mods] 2016-06-20T20:28:38Z Bill Erickson <berickxx@gmail.com> # Updating in-db export utilities
+purge-holds [audit-table-maint] 2016-09-21T16:01:57Z Bill Erickson <berickxx@gmail.com> # Holds purge settings
 2.7-to-2.9-upgrade [backstage-exports-continued] 2016-12-09T20:27:17Z Bill Erickson <berickxx@gmail.com> # 2.7 to 2.9 Upgrade
 2.7-to-2.9-upgrade-part-2 [2.7-to-2.9-upgrade] 2016-12-12T15:19:07Z Bill Erickson <berickxx@gmail.com> # 2.7 to 2.9 Upgrade Secondary Updates
diff --git a/KCLS/sql/schema/verify/purge-holds.sql b/KCLS/sql/schema/verify/purge-holds.sql
new file mode 100644 (file)
index 0000000..fd7a2fc
--- /dev/null
@@ -0,0 +1,7 @@
+-- Verify kcls-evergreen:purge-holds on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;
index 4cad848..777b04c 100644 (file)
@@ -128,6 +128,9 @@ BACKSTAGE_PASSWORD = BSPASS
 #0 0 * * 5 cd $SCRIPT_DIR/purge_circs/ && ./purge_circulations.sh --start 2013-01-01 --end 2014-01-01 --increment "1 year" --duration 120 >> /openils/var/log/purge_circs.log
 #0 0 * * 6 cd $SCRIPT_DIR/purge_circs/ && ./purge_circulations.sh --start 2014-01-01 --end $(date -d -1year-1month +'\%F') --increment "1 year" --duration 120 >> /openils/var/log/purge_circs.log
 
+# Nightly holds purging
+30 1 * * * cd $SCRIPT_DIR/purge_holds/ && ./purge_holds.sh
+
 # Process and archive student import files each Sunday night at 11pm
 # 0 23 * * 0 cd /home/opensrf/Evergreen/KCLS/utility-scripts/import_students && ./sftp-client-agent.sh -b db01 -p -a
 
diff --git a/KCLS/utility-scripts/purge_holds/purge_holds.sh b/KCLS/utility-scripts/purge_holds/purge_holds.sh
new file mode 100755 (executable)
index 0000000..9f0360b
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+# Kick off the holds purge function.
+# Set PGHOST, PGPASSWORD, PGUSER environment variables!
+set -eu
+PSQL="psql"
+
+echo -n "Purging holds at "
+date +"%F %T" 
+
+echo "SET STATEMENT_TIMEOUT = 0; SELECT action.purge_holds();" | $PSQL;
+
+echo -n "Purging holds complete at "
+date +"%F %T"