To spin up a server against the prod database:
bun run dev
Open http://localhost:3000 with your browser to see the result.
Or run bun run dev:dev
to connect to the dev database.
You'll need the supabase client and admin keys. After you've been added to the Vercel project, get them with:
bunx vercel link
bunx vercel env pull
You'll want to do this if we've changed the prod database schema (eg through the Supabase web UI).
-
Authenticate to snaplet with
npx snaplet auth setup
-
Go to https://app.snaplet.dev/ and create a new snapshot.
-
Run
bun run snap:restore
(orbun run snap:restore-empty
, which is less likely to miss a table)- You might need to add a
.snaplet/config.json
file with eg
{ "projectId": "clej64eho0387lyqivt8o85zx", "targetDatabaseUrl": "postgres://postgres:[password]@db.oucjhqqretizqonyfyqu.supabase.co:6543/postgres" }
- You might need to add a
-
Run the following SQL code on the dev db (
Regrant permissions
):grant usage on schema public to postgres, anon, authenticated, service_role; grant all privileges on all tables in schema public to postgres, anon, authenticated, service_role, supabase_admin; grant all privileges on all functions in schema public to postgres, anon, authenticated, service_role, supabase_admin; grant all privileges on all sequences in schema public to postgres, anon, authenticated, service_role, supabase_admin; alter default privileges in schema public grant all on tables to postgres, anon, authenticated, service_role; alter default privileges in schema public grant all on functions to postgres, anon, authenticated, service_role; alter default privileges in schema public grant all on sequences to postgres, anon, authenticated, service_role;
-
Restart the database on eg https://app.supabase.com/project/oucjhqqretizqonyfyqu/settings/general to clear the cache
To test the Stripe webhook integration, you'll need to install the Stripe CLI, then run
stripe listen --forward-to localhost:3000/api/stripe-endpoints
npx supabase gen types typescript --project-id fkousziwzbnkdkldjper --schema public > db/database.types.ts
Note that bun/bunx has some problems with the supabase
cli, so just use npx here.