From: Dan Wells Date: Fri, 23 Aug 2013 23:33:58 +0000 (-0400) Subject: Stamping upgrade for patron self-reg X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3613e273d1d0d399e35389a009affc7d31b83f79;p=evergreen%2Fmasslnc.git Stamping upgrade for patron self-reg Signed-off-by: Dan Wells --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 62e2eddb11..cb7fb8cb78 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps BEFORE INSERT OR UPDATE ON config.db_patch_dependencies FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates'); -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0820', :eg_version); -- callender/miker +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0823', :eg_version); -- berick/dbwells CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0823.schema.patron-self-reg.sql b/Open-ILS/src/sql/Pg/upgrade/0823.schema.patron-self-reg.sql new file mode 100644 index 0000000000..9fe041ca01 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0823.schema.patron-self-reg.sql @@ -0,0 +1,102 @@ + +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('0823', :eg_version); + +-- Track the requesting user +ALTER TABLE staging.user_stage + ADD COLUMN requesting_usr INTEGER + REFERENCES actor.usr(id) ON DELETE SET NULL; + +-- add county column to staged address tables and +-- drop state requirement to match actor.usr_address +ALTER TABLE staging.mailing_address_stage + ADD COLUMN county TEXT, + ALTER COLUMN state DROP DEFAULT, + ALTER COLUMN state DROP NOT NULL; + +ALTER TABLE staging.billing_address_stage + ADD COLUMN county TEXT, + ALTER COLUMN state DROP DEFAULT, + ALTER COLUMN state DROP NOT NULL; + +-- stored procedure for deleting expired pending patrons +CREATE OR REPLACE FUNCTION staging.purge_pending_users() RETURNS VOID AS $$ +DECLARE + org_id INT; + intvl TEXT; +BEGIN + FOR org_id IN SELECT DISTINCT(home_ou) FROM staging.user_stage LOOP + + SELECT INTO intvl value FROM + actor.org_unit_ancestor_setting( + 'opac.pending_user_expire_interval', org_id); + + CONTINUE WHEN intvl IS NULL OR intvl ILIKE 'null'; + + -- de-JSON-ify the string + SELECT INTO intvl TRIM(BOTH '"' FROM intvl); + + DELETE FROM staging.user_stage + WHERE home_ou = org_id AND row_date + intvl::INTERVAL < NOW(); + + END LOOP; +END; +$$ LANGUAGE PLPGSQL; + + +INSERT INTO config.org_unit_setting_type + (name, grp, datatype, label, description) +VALUES ( + 'opac.allow_pending_user', + 'opac', + 'bool', + oils_i18n_gettext( + 'opac.allow_pending_user', + 'Allow Patron Self-Registration', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'opac.allow_pending_user', + 'Allow patrons to self-register, creating pending user accounts', + 'coust', + 'description' + ) +), ( + 'opac.pending_user_expire_interval', + 'opac', + 'interval', + oils_i18n_gettext( + 'opac.pending_user_expire_interval', + 'Patron Self-Reg. Expire Interval', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'opac.pending_user_expire_interval', + 'If set, this is the amount of time a pending user account will ' || + 'be allowed to sit in the database. After this time, the pending ' || + 'user information will be purged', + 'coust', + 'description' + ) +), ( + 'ui.patron.edit.aua.county.show', + 'gui', + 'bool', + oils_i18n_gettext( + 'ui.patron.edit.aua.county.require', + 'Show county field on patron registration', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'ui.patron.edit.aua.county.require', + 'The county field will be shown on the patron registration screen', + 'coust', + 'description' + ) +); + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.patron-self-reg.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.patron-self-reg.sql deleted file mode 100644 index b14f1ea4c4..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.patron-self-reg.sql +++ /dev/null @@ -1,100 +0,0 @@ - -BEGIN; - --- Track the requesting user -ALTER TABLE staging.user_stage - ADD COLUMN requesting_usr INTEGER - REFERENCES actor.usr(id) ON DELETE SET NULL; - --- add county column to staged address tables and --- drop state requirement to match actor.usr_address -ALTER TABLE staging.mailing_address_stage - ADD COLUMN county TEXT, - ALTER COLUMN state DROP DEFAULT, - ALTER COLUMN state DROP NOT NULL; - -ALTER TABLE staging.billing_address_stage - ADD COLUMN county TEXT, - ALTER COLUMN state DROP DEFAULT, - ALTER COLUMN state DROP NOT NULL; - --- stored procedure for deleting expired pending patrons -CREATE OR REPLACE FUNCTION staging.purge_pending_users() RETURNS VOID AS $$ -DECLARE - org_id INT; - intvl TEXT; -BEGIN - FOR org_id IN SELECT DISTINCT(home_ou) FROM staging.user_stage LOOP - - SELECT INTO intvl value FROM - actor.org_unit_ancestor_setting( - 'opac.pending_user_expire_interval', org_id); - - CONTINUE WHEN intvl IS NULL OR intvl ILIKE 'null'; - - -- de-JSON-ify the string - SELECT INTO intvl TRIM(BOTH '"' FROM intvl); - - DELETE FROM staging.user_stage - WHERE home_ou = org_id AND row_date + intvl::INTERVAL < NOW(); - - END LOOP; -END; -$$ LANGUAGE PLPGSQL; - - -INSERT INTO config.org_unit_setting_type - (name, grp, datatype, label, description) -VALUES ( - 'opac.allow_pending_user', - 'opac', - 'bool', - oils_i18n_gettext( - 'opac.allow_pending_user', - 'Allow Patron Self-Registration', - 'coust', - 'label' - ), - oils_i18n_gettext( - 'opac.allow_pending_user', - 'Allow patrons to self-register, creating pending user accounts', - 'coust', - 'description' - ) -), ( - 'opac.pending_user_expire_interval', - 'opac', - 'interval', - oils_i18n_gettext( - 'opac.pending_user_expire_interval', - 'Patron Self-Reg. Expire Interval', - 'coust', - 'label' - ), - oils_i18n_gettext( - 'opac.pending_user_expire_interval', - 'If set, this is the amount of time a pending user account will ' || - 'be allowed to sit in the database. After this time, the pending ' || - 'user information will be purged', - 'coust', - 'description' - ) -), ( - 'ui.patron.edit.aua.county.show', - 'gui', - 'bool', - oils_i18n_gettext( - 'ui.patron.edit.aua.county.require', - 'Show county field on patron registration', - 'coust', - 'label' - ), - oils_i18n_gettext( - 'ui.patron.edit.aua.county.require', - 'The county field will be shown on the patron registration screen', - 'coust', - 'description' - ) -); - -COMMIT;