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:
- Create a new schema
CREATE SCHEMA myproject
- 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;
- Add it as an exposed schema in Supabase settings