diff --git a/supabase/migrations/20240410192929_fix-pg-cron.sql b/supabase/migrations/20240410192929_fix-pg-cron.sql new file mode 100644 index 0000000..44ab566 --- /dev/null +++ b/supabase/migrations/20240410192929_fix-pg-cron.sql @@ -0,0 +1,25 @@ +select cron.unschedule(jobs.jobid) FROM cron.job jobs; +drop extension if exists pg_cron; +create extension if not exists pg_cron; + +grant usage on schema cron to postgres; +grant all privileges on all tables in schema cron to postgres; + +-- restore the jobs +SELECT + cron.schedule( + 'drop-old-chunks', + '*/10 * * * *', + $$ + SELECT drop_chunks('raw_bus_positions', INTERVAL '24 hours'); + $$ + ); + +SELECT + cron.schedule( + 'download-bus-data', + '5 seconds', + $$ + select gather_bus_data(); + $$ + );