Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Evergreen Circ History - Allow staff to enable/disable
-- Look for preference set to null, blank or false and remove it.
delete from actor.usr_setting aus
and (aus.value is null or aus.value = 'false' or aus.value='')
returning aus.*
-- Look for users with circ history but no preference.
create temp table user_orphan_history
on commit drop
select auch.usr, count(
from action.usr_circ_history auch
left outer join actor.usr_setting aus on aus.usr=auch.usr and'history.circ.retention_start'
join actor.usr au on
aus.value is null
and not au.deleted
-- Sanity check, don't do anything if the preference definition has changed or if it isn't used any more,
-- Just in case the preference name is changed in the future and automaticlaly updated to a new value
and exists (select 1 from config.usr_setting_type cust where'history.circ.retention_start')
and exists (select 1 from actor.usr_setting aus where name='history.circ.retention_start' limit 1)
group by 1;
select * from user_orphan_history;
delete from action.usr_circ_history auch
using user_orphan_history uoh
returning auch.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.