4 SELECT evergreen.upgrade_deps_block_check('0993', :eg_version);
6 ALTER TABLE config.usr_activity_type
7 ALTER COLUMN transient SET DEFAULT TRUE;
9 -- Utility function for removing all activity entries by activity type,
10 -- except for the most recent entry per user. This is primarily useful
11 -- when cleaning up rows prior to setting the transient flag on an
12 -- activity type to true. It allows for immediate cleanup of data (e.g.
13 -- for patron privacy) and lets admins control when the data is deleted,
14 -- which could be useful for huge activity tables.
16 CREATE OR REPLACE FUNCTION
17 actor.purge_usr_activity_by_type(act_type INTEGER)
22 FOR cur_usr IN SELECT DISTINCT(usr)
23 FROM actor.usr_activity WHERE etype = act_type LOOP
24 DELETE FROM actor.usr_activity WHERE id IN (
26 FROM actor.usr_activity
27 WHERE usr = cur_usr AND etype = act_type
28 ORDER BY event_time DESC OFFSET 1
32 END $$ LANGUAGE PLPGSQL;