--- /dev/null
+-- Deploy kcls-evergreen:org-unit-addrs-copy to pg
+-- requires: sip-activity-types
+BEGIN;
+
+-- Create a copy of address id=1 for each org unit that
+-- currently links to address id=1
+
+INSERT INTO actor.org_address (org_unit, address_type,
+ street1, street2, city, county, state, country, post_code, san)
+ SELECT aou.id, aua.address_type, aua.street1, aua.street2,
+ aua.city, aua.county, aua.state, aua.country, aua.post_code, aua.san
+ FROM actor.org_unit aou
+ JOIN actor.org_address aua ON (aua.id = aou.mailing_address)
+ WHERE aou.id <> 1;
+
+-- Update each org unit to use the newly created address whose
+-- owning org unit value matches. Ignore existing addresses.
+
+UPDATE actor.org_unit aou
+ SET mailing_address = (
+ SELECT aua.id
+ FROM actor.org_address aua
+ WHERE aua.org_unit = aou.id
+ -- avoid using addresses that existed before this script ran
+ AND aua.id NOT IN (1, 5, 6)
+ )
+ WHERE id <> 1 AND mailing_address = 1;
+
+COMMIT;
+
--- /dev/null
+-- Revert kcls-evergreen:org-unit-addrs-copy from pg
+
+BEGIN;
+
+UPDATE actor.org_unit
+ SET mailing_address = 1
+ WHERE mailing_address IS NOT NULL
+ AND mailing_address NOT IN (5, 6);
+
+DELETE FROM actor.org_address WHERE id NOT IN (1, 5, 6);
+
+COMMIT;
patron-self-reg-mods [blanket-po-print-template] 2016-01-13T20:14:00Z Bill Erickson <berickxx@gmail.com> # Patron self-reg customizations
sip-activity-types [2.7-auth-reingest] 2016-03-15T21:30:39Z Bill Erickson <berickxx@gmail.com> # User activity types for hoopla/lynda SIP auth
ingram-edi-mods [sip-activity-types] 2016-05-24T16:31:46Z Bill Erickson <berickxx@gmail.com> # Ingram EDI config updates
+org-unit-addrs-copy [sip-activity-types] 2016-05-03T14:17:59Z Bill Erickson <berickxx@gmail.com> # Give each org unit its own mailing address