Skip to content

Commit

Permalink
feat: add cron migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveantor committed Aug 29, 2023
1 parent 0aecb85 commit 9e53e1a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions supabase/migrations/20230829101134_setup_cron.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Enable the pg_cron extension
CREATE EXTENSION IF NOT EXISTS pg_cron;

-- Runs everyday at 03:00 AM to cleanup logs that are older than a week
-- Use the cron time format to modify the trigger time if necessary
SELECT
cron.schedule(
'logs-cleaner', -- Job name
'0 3 * * *', -- Everyday at 03:00 AM
$$DELETE FROM logs WHERE timestamp < now() - INTERVAL '1 week'$$
);

0 comments on commit 9e53e1a

Please sign in to comment.