On Thursday, December 10, 2015 at 11:35:31 AM UTC-7, cootcraig wrote:
>
> Advice on this is welcome. I am not concerned about support for
> anything but Postgresql right now.
>
> Here's what I came up with.
Sequel.migration do
up do
run <<-prune
CREATE OR REPLACE FUNCTION
prune_table()
RETURNS
INTEGER
AS $$
DECLARE
delete_count INTEGER;
BEGIN
DELETE FROM
table
WHERE
(current_date - read_at::date) > 14;
GET DIAGNOSTICS
delete_count = ROW_COUNT;
RETURN delete_count;
END;
$$ LANGUAGE plpgsql;
prune
down do
run <<-drop
DROP FUNCTION IF EXISTS
prune_table();
drop
end
end
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.