4 -- Track the requesting user
5 ALTER TABLE staging.user_stage
6 ADD COLUMN requesting_usr INTEGER
7 REFERENCES actor.usr(id) ON DELETE SET NULL;
9 -- add county column to staged address tables and
10 -- drop state requirement to match actor.usr_address
11 ALTER TABLE staging.mailing_address_stage
12 ADD COLUMN county TEXT,
13 ALTER COLUMN state DROP DEFAULT,
14 ALTER COLUMN state DROP NOT NULL;
16 ALTER TABLE staging.billing_address_stage
17 ADD COLUMN county TEXT,
18 ALTER COLUMN state DROP DEFAULT,
19 ALTER COLUMN state DROP NOT NULL;
21 -- stored procedure for deleting expired pending patrons
22 CREATE OR REPLACE FUNCTION staging.purge_pending_users() RETURNS VOID AS $$
27 FOR org_id IN SELECT DISTINCT(home_ou) FROM staging.user_stage LOOP
29 SELECT INTO intvl value FROM
30 actor.org_unit_ancestor_setting(
31 'opac.pending_user_expire_interval', org_id);
33 CONTINUE WHEN intvl IS NULL OR intvl ILIKE 'null';
35 -- de-JSON-ify the string
36 SELECT INTO intvl TRIM(BOTH '"' FROM intvl);
38 DELETE FROM staging.user_stage
39 WHERE home_ou = org_id AND row_date + intvl::INTERVAL < NOW();
46 INSERT INTO config.org_unit_setting_type
47 (name, grp, datatype, label, description)
49 'opac.allow_pending_user',
53 'opac.allow_pending_user',
54 'Allow Patron Self-Registration',
59 'opac.allow_pending_user',
60 'Allow patrons to self-register, creating pending user accounts',
65 'opac.pending_user_expire_interval',
69 'opac.pending_user_expire_interval',
70 'Patron Self-Reg. Expire Interval',
75 'opac.pending_user_expire_interval',
76 'If set, this is the amount of time a pending user account will ' ||
77 'be allowed to sit in the database. After this time, the pending ' ||
78 'user information will be purged',
83 'ui.patron.edit.aua.county.show',
87 'ui.patron.edit.aua.county.require',
88 'Show count field on patron registration',
93 'ui.patron.edit.aua.county.require',
94 'The county field will be shown on the patron registration screen',