Advertisement
roganhamby

Juvenile Account Cleanup

Dec 20th, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. -- juvenile -> adult
  3. UPDATE actor.usr SET profile = 379, juvenile = FALSE WHERE id IN
  4.     ( SELECT au.id FROM actor.usr au
  5.     JOIN actor.org_unit aou ON aou.id = au.home_ou
  6.     JOIN permission.grp_tree pgt ON pgt.id = au.profile
  7.     WHERE aou.shortname ILIKE 'bcl%' AND pgt.NAME = 'Juvenile'
  8.     AND au.dob < NOW() - INTERVAL '18 years' )
  9. ;
  10.  
  11. -- juvenile non-residen -> adult non-resident
  12. UPDATE actor.usr SET profile = 380, juvenile = FALSE WHERE id IN
  13.     ( SELECT au.id FROM actor.usr au
  14.     JOIN actor.org_unit aou ON aou.id = au.home_ou
  15.     JOIN permission.grp_tree pgt ON pgt.id = au.profile
  16.     WHERE aou.shortname ILIKE 'bcl%' AND pgt.NAME = 'Juvenile Non-Resident'
  17.     AND au.dob < NOW() - INTERVAL '18 years' )
  18. ;
  19.  
  20. -- teen -> adult
  21. UPDATE actor.usr SET profile = 379, juvenile = FALSE WHERE id IN
  22.     ( SELECT au.id FROM actor.usr au
  23.     JOIN actor.org_unit aou ON aou.id = au.home_ou
  24.     JOIN permission.grp_tree pgt ON pgt.id = au.profile
  25.     WHERE aou.shortname ILIKE 'bcl%' AND pgt.NAME = 'Teen'
  26.     AND au.dob < NOW() - INTERVAL '18 years' )
  27. ;
  28.  
  29. -- teen non-residen -> adult non-resident
  30. UPDATE actor.usr SET profile = 380, juvenile = FALSE WHERE id IN
  31.     ( SELECT au.id FROM actor.usr au
  32.     JOIN actor.org_unit aou ON aou.id = au.home_ou
  33.     JOIN permission.grp_tree pgt ON pgt.id = au.profile
  34.     WHERE aou.shortname ILIKE 'bcl%' AND pgt.NAME = 'Teen Non-Resident'
  35.     AND au.dob < NOW() - INTERVAL '18 years' )
  36. ;
  37.  
  38. -- juv to teen by bcl rules
  39. UPDATE actor.usr SET profile = 389, juvenile = TRUE WHERE id IN
  40.     ( SELECT au.id FROM actor.usr au
  41.     JOIN actor.org_unit aou ON aou.id = au.home_ou
  42.     JOIN permission.grp_tree pgt ON pgt.id = au.profile
  43.     WHERE aou.shortname ILIKE 'bcl%' AND pgt.NAME = 'Juvenile'
  44.     AND au.dob < NOW() - INTERVAL '12 years' )
  45. ;
  46.  
  47. -- juv non-residen -> teen non-resident
  48. UPDATE actor.usr SET profile = 390, juvenile = TRUE WHERE id IN
  49.     ( SELECT au.id FROM actor.usr au
  50.     JOIN actor.org_unit aou ON aou.id = au.home_ou
  51.     JOIN permission.grp_tree pgt ON pgt.id = au.profile
  52.     WHERE aou.shortname ILIKE 'bcl%' AND pgt.NAME = 'Juvenile Non-Resident'
  53.     AND au.dob < NOW() - INTERVAL '12 years' )
  54. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement