Advertisement
roganhamby

Wiping Patrons

Dec 30th, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- This is my wipe patron information script.
  2. -- We remove identifiying information and put standards in so that we can identify when a patron has been deleted by renaming the user.
  3. -- This way we can reconcile historical reports with current amount and say things like 'amount x is unrecoverable because it is for deleted patrons.'
  4. -- We remove a patron upon request if the account is in good standing but keep a lot of information for statistical reports and historical analysis but nothing that will identify a patron.  
  5. -- The first two sql updates here are what we use but you may want to consider some variants.
  6.  
  7. update actor.usr set (email,first_given_name,second_given_name,family_name,usrname,ident_value,ident_value2,suffix,day_phone,evening_phone,other_phone,active,barred,deleted,alert_message)
  8. = (NULL,'DELETED',NULL,'PATRON',id,NULL,NULL,NULL,NULL,NULL,Null,FALSE,TRUE,TRUE,NULL) where id = 1234567;
  9.  
  10. update actor.usr_address set (street1,street2) = ('138 Lifted Lorax Street',NULL) where usr = 1234567;
  11.  
  12. -- Two things.  One, you could combine these into one statement but they're simple enough that they can run sequentially in a cron job or manually.  
  13. -- I like keeping updates to a single table but that's me, I'm conservative.
  14.  
  15. -- We only wipe individual patrons upon request but if you're looking to wipe by expiration that's a simple change to the first one.
  16. -- If you're looking to use activity date you will also want to look at creation date to protect those created within the last three years.
  17. -- If you have migration libraries to consider you will want to look at your data carefully and make sure you didn't migrate in from old records
  18. -- old creation dates.  If you did you will need to either a) update those to migration dates, b) account for that in the code somehow or c) create
  19. -- dummy activity entries for them in usr.activity.  Depending upon how you're using it you could also use the expiration date which is simpler
  20. -- but has some significant drawbacks and may just be a plain bad idea depening upon how you're using it.
  21.  
  22. -- Also, think about alerts.  We wipe individuals so we don't worry about this but if libraries are using alerts and barred to denote patrons they
  23. -- want to keep a record of you may want to create conditionals to skip those.  
  24.  
  25. -- In these bulk update scenarios you could change the address update to just update everything that matches the name conventions and was updated today and
  26. -- the cron could take it from there.  You could skip the today part but then that's more auditor entries and it will take progressively longer to run
  27. -- everytime you use it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement