© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
2 replies
Profilüfter

Enable pg_cron in a migration

I'm currently trying to use the pg_cron extension. However when I try to enable it in a migration using
CREATE EXTENSION pg_cron;
CREATE EXTENSION pg_cron;
I get the following error:
Error: Error starting database: ERROR:  can only create extension in database postgres
DETAIL:  Jobs must be scheduled from the database configured in cron.database_name, since the pg_cron background worker reads job de
scriptions from this database.
HINT:  Add cron.database_name = 'main' in postgresql.conf to use the current database.
CONTEXT:  PL/pgSQL function inline_code_block line 4 at RAISE
Error: Error starting database: ERROR:  can only create extension in database postgres
DETAIL:  Jobs must be scheduled from the database configured in cron.database_name, since the pg_cron background worker reads job de
scriptions from this database.
HINT:  Add cron.database_name = 'main' in postgresql.conf to use the current database.
CONTEXT:  PL/pgSQL function inline_code_block line 4 at RAISE

It's probably because the Supabase CLI creates a database named after the current branch (default
main
main
) and only later renames it to
postgres
postgres
.
Is there a way around this? If I try to enable the extension after I started the server it does work however I need to be able to use it in migrations.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Cannot enable PG_CRON in self hosted Supabase
SupabaseSSupabase / help-and-questions
3y ago
Enable realtime CDC in a migration?
SupabaseSSupabase / help-and-questions
4y ago
testing cron jobs with pg_cron
SupabaseSSupabase / help-and-questions
4y ago
Enable extensions in migration failed
SupabaseSSupabase / help-and-questions
3y ago