LP#1802166: stamp schema update
authorGalen Charlton <gmc@equinoxinitiative.org>
Mon, 27 Jul 2020 14:55:19 +0000 (10:55 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 27 Jul 2020 14:55:19 +0000 (10:55 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/1211.function.actor_usr_delete.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.function.actor_usr_delete.sql [deleted file]

index f02ba5f..02bab54 100644 (file)
@@ -92,7 +92,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 ('1210', :eg_version); -- csharp/rhamby/sandbergja/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1211', :eg_version); -- Dyrcona/rhamby/gmcharlt
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1211.function.actor_usr_delete.sql b/Open-ILS/src/sql/Pg/upgrade/1211.function.actor_usr_delete.sql
new file mode 100644 (file)
index 0000000..334fe41
--- /dev/null
@@ -0,0 +1,125 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1211', :eg_version); -- Dyrcona/rhamby/gmcharlt
+
+CREATE OR REPLACE FUNCTION actor.usr_delete(
+       src_usr  IN INTEGER,
+       dest_usr IN INTEGER
+) RETURNS VOID AS $$
+DECLARE
+       old_profile actor.usr.profile%type;
+       old_home_ou actor.usr.home_ou%type;
+       new_profile actor.usr.profile%type;
+       new_home_ou actor.usr.home_ou%type;
+       new_name    text;
+       new_dob     actor.usr.dob%type;
+BEGIN
+       SELECT
+               id || '-PURGED-' || now(),
+               profile,
+               home_ou,
+               dob
+       INTO
+               new_name,
+               old_profile,
+               old_home_ou,
+               new_dob
+       FROM
+               actor.usr
+       WHERE
+               id = src_usr;
+       --
+       -- Quit if no such user
+       --
+       IF old_profile IS NULL THEN
+               RETURN;
+       END IF;
+       --
+       perform actor.usr_purge_data( src_usr, dest_usr );
+       --
+       -- Find the root grp_tree and the root org_unit.  This would be simpler if we 
+       -- could assume that there is only one root.  Theoretically, someday, maybe,
+       -- there could be multiple roots, so we take extra trouble to get the right ones.
+       --
+       SELECT
+               id
+       INTO
+               new_profile
+       FROM
+               permission.grp_ancestors( old_profile )
+       WHERE
+               parent is null;
+       --
+       SELECT
+               id
+       INTO
+               new_home_ou
+       FROM
+               actor.org_unit_ancestors( old_home_ou )
+       WHERE
+               parent_ou is null;
+       --
+       -- Truncate date of birth
+       --
+       IF new_dob IS NOT NULL THEN
+               new_dob := date_trunc( 'year', new_dob );
+       END IF;
+       --
+       UPDATE
+               actor.usr
+               SET
+                       card = NULL,
+                       profile = new_profile,
+                       usrname = new_name,
+                       email = NULL,
+                       passwd = random()::text,
+                       standing = DEFAULT,
+                       ident_type = 
+                       (
+                               SELECT MIN( id )
+                               FROM config.identification_type
+                       ),
+                       ident_value = NULL,
+                       ident_type2 = NULL,
+                       ident_value2 = NULL,
+                       net_access_level = DEFAULT,
+                       photo_url = NULL,
+                       prefix = NULL,
+                       first_given_name = new_name,
+                       second_given_name = NULL,
+                       family_name = new_name,
+                       suffix = NULL,
+                       alias = NULL,
+            guardian = NULL,
+                       day_phone = NULL,
+                       evening_phone = NULL,
+                       other_phone = NULL,
+                       mailing_address = NULL,
+                       billing_address = NULL,
+                       home_ou = new_home_ou,
+                       dob = new_dob,
+                       active = FALSE,
+                       master_account = DEFAULT, 
+                       super_user = DEFAULT,
+                       barred = FALSE,
+                       deleted = TRUE,
+                       juvenile = DEFAULT,
+                       usrgroup = 0,
+                       claims_returned_count = DEFAULT,
+                       credit_forward_balance = DEFAULT,
+                       last_xact_id = DEFAULT,
+                       alert_message = NULL,
+                       pref_prefix = NULL,
+                       pref_first_given_name = NULL,
+                       pref_second_given_name = NULL,
+                       pref_family_name = NULL,
+                       pref_suffix = NULL,
+                       name_keywords = NULL,
+                       create_date = now(),
+                       expire_date = now()
+       WHERE
+               id = src_usr;
+END;
+$$ LANGUAGE plpgsql;
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.actor_usr_delete.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.actor_usr_delete.sql
deleted file mode 100644 (file)
index 12fcdb7..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-BEGIN;
-
---SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-CREATE OR REPLACE FUNCTION actor.usr_delete(
-       src_usr  IN INTEGER,
-       dest_usr IN INTEGER
-) RETURNS VOID AS $$
-DECLARE
-       old_profile actor.usr.profile%type;
-       old_home_ou actor.usr.home_ou%type;
-       new_profile actor.usr.profile%type;
-       new_home_ou actor.usr.home_ou%type;
-       new_name    text;
-       new_dob     actor.usr.dob%type;
-BEGIN
-       SELECT
-               id || '-PURGED-' || now(),
-               profile,
-               home_ou,
-               dob
-       INTO
-               new_name,
-               old_profile,
-               old_home_ou,
-               new_dob
-       FROM
-               actor.usr
-       WHERE
-               id = src_usr;
-       --
-       -- Quit if no such user
-       --
-       IF old_profile IS NULL THEN
-               RETURN;
-       END IF;
-       --
-       perform actor.usr_purge_data( src_usr, dest_usr );
-       --
-       -- Find the root grp_tree and the root org_unit.  This would be simpler if we 
-       -- could assume that there is only one root.  Theoretically, someday, maybe,
-       -- there could be multiple roots, so we take extra trouble to get the right ones.
-       --
-       SELECT
-               id
-       INTO
-               new_profile
-       FROM
-               permission.grp_ancestors( old_profile )
-       WHERE
-               parent is null;
-       --
-       SELECT
-               id
-       INTO
-               new_home_ou
-       FROM
-               actor.org_unit_ancestors( old_home_ou )
-       WHERE
-               parent_ou is null;
-       --
-       -- Truncate date of birth
-       --
-       IF new_dob IS NOT NULL THEN
-               new_dob := date_trunc( 'year', new_dob );
-       END IF;
-       --
-       UPDATE
-               actor.usr
-               SET
-                       card = NULL,
-                       profile = new_profile,
-                       usrname = new_name,
-                       email = NULL,
-                       passwd = random()::text,
-                       standing = DEFAULT,
-                       ident_type = 
-                       (
-                               SELECT MIN( id )
-                               FROM config.identification_type
-                       ),
-                       ident_value = NULL,
-                       ident_type2 = NULL,
-                       ident_value2 = NULL,
-                       net_access_level = DEFAULT,
-                       photo_url = NULL,
-                       prefix = NULL,
-                       first_given_name = new_name,
-                       second_given_name = NULL,
-                       family_name = new_name,
-                       suffix = NULL,
-                       alias = NULL,
-            guardian = NULL,
-                       day_phone = NULL,
-                       evening_phone = NULL,
-                       other_phone = NULL,
-                       mailing_address = NULL,
-                       billing_address = NULL,
-                       home_ou = new_home_ou,
-                       dob = new_dob,
-                       active = FALSE,
-                       master_account = DEFAULT, 
-                       super_user = DEFAULT,
-                       barred = FALSE,
-                       deleted = TRUE,
-                       juvenile = DEFAULT,
-                       usrgroup = 0,
-                       claims_returned_count = DEFAULT,
-                       credit_forward_balance = DEFAULT,
-                       last_xact_id = DEFAULT,
-                       alert_message = NULL,
-                       pref_prefix = NULL,
-                       pref_first_given_name = NULL,
-                       pref_second_given_name = NULL,
-                       pref_family_name = NULL,
-                       pref_suffix = NULL,
-                       name_keywords = NULL,
-                       create_date = now(),
-                       expire_date = now()
-       WHERE
-               id = src_usr;
-END;
-$$ LANGUAGE plpgsql;
-
-COMMIT;