Skip to content

Instantly share code, notes, and snippets.

@davehague
Last active September 19, 2024 14:06
Show Gist options
  • Save davehague/5f694889f466d18c5b48fda89ddfc14a to your computer and use it in GitHub Desktop.
Save davehague/5f694889f466d18c5b48fda89ddfc14a to your computer and use it in GitHub Desktop.
Supabase Multi-Project Project

Supabase only allows two projects to be active at any given time on their free tier. However, if you're like me and you like to explore and create a lot of projects, you'll be frustated with having to spin them down and up.

To solve this, use Postgres schemas. A PostgreSQL schema is a namespace that groups together database objects such as tables, views, indexes, data types, functions, and operators. It allows you to organize your data and objects within a database in a way that makes sense for your application.

Supabase actually has a page on how to use schemas. The short of it is below:

  1. Create a new schema
CREATE SCHEMA myproject
  1. Grant access to the schema
GRANT USAGE ON SCHEMA myproject TO anon, authenticated, service_role;
GRANT ALL ON ALL TABLES IN SCHEMA myproject TO anon, authenticated, service_role;
GRANT ALL ON ALL ROUTINES IN SCHEMA myproject TO anon, authenticated, service_role;
GRANT ALL ON ALL SEQUENCES IN SCHEMA myproject TO anon, authenticated, service_role;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA myproject GRANT ALL ON TABLES TO anon, authenticated, service_role;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA myproject GRANT ALL ON ROUTINES TO anon, authenticated, service_role;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA myproject GRANT ALL ON SEQUENCES TO anon, authenticated, service_role;
  1. Add it as an exposed schema in Supabase settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment