Created
October 1, 2019 20:39
-
-
Save theory/8c320bde6494f19afcdbe93a1a72b828 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO $$ | |
DECLARE | |
target TEXT; | |
BEGIN | |
FOR target IN | |
SELECT table_name | |
FROM information_schema.tables | |
WHERE table_schema = 'bucardo' | |
AND table_name LIKE 'track_%' | |
LOOP | |
EXECUTE format( | |
'DELETE FROM bucardo.%I WHERE txntime < %L', | |
target, NOW() - '30 DAYS'::interval | |
); | |
EXECUTE format( | |
'DELETE FROM bucardo.%I WHERE txntime < %L', | |
replace(target, 'track', 'delta'), | |
NOW() - '30 DAYS'::interval | |
); | |
END LOOP; | |
END; | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment