Skip to main content

Supabase

Supabase is the main OLTP database that we use for user operations on the website.

Production Setup

  • Database >> Extensions
    • Enable the "plpgsql", "plv8" and "pgjwt" extensions
  • Authentication >> Providers
    • Turn on the Google and GitHub provider
  • Authentication >> URL Configuration
    • Add allowed redirect URIs
      • https://www.opensource.observer/**
      • http://localhost:3000/**
  • Authentication >> Hooks
    • Enable the "hasura_token_hook" hook under the "public" schema
  • Settings >> Authentication
    • Turn on "Allow new users to sign up"

Run the Supabase migrations to create the tables and functions required for the OSO project.

cd apps/frontend/
pnpm supabase db push

Local Setup

Setup

From apps/frontend:

pnpm install
pnpm approve-builds

Running local dev Supabase instance

# Start the background service
pnpm supabase start
# Stop the background service
pnpm supabase stop

Reset local state

pnpm supabase db reset

Migrations

For updating the database schema or functions, make sure to put it in a migration.

pnpm supabase migration new

After editing the migration, you can apply it to production with:

pnpm supabase db push

If you need to see which migrations have been applied, you can run:

pnpm migration list

To squash migrations into a single file:

pnpm supabase migration squash

To compare your local database with production and auto-generate a migration of the diff

pnpm supabase db diff

For more details, check out the Supabase docs.