Skip to main content

Staging Environment Setup

Overview

main → production (shikshaos.triverseinfotech.com)
staging → staging (staging-shikshaos.vercel.app or custom subdomain)

One-time setup

1. Create a staging Supabase project

Go to supabase.com → New project → name it shikshaos-staging. Apply all migrations to it:

2. Create the staging git branch

3. Configure Vercel

In the Vercel dashboard for this project:
  1. Settings → Git → Production Branch — keep as main
  2. Settings → Environment Variables — for each variable in .env.staging.example, add it scoped to Preview and set Git branch = staging
Key env vars to scope to staging only: Variables that can be shared with production (same values):
  • NEXT_PUBLIC_LIVEKIT_* — can point to same LiveKit instance
  • SENTRY_DSN — same project, different environment tag

4. Verify the staging deploy

Vercel auto-deploys the staging branch to a preview URL. Check the Vercel dashboard for the URL.

Deploy workflow

  1. Develop on a feature branch
  2. Open PR against main — Vercel creates an ephemeral preview URL
  3. After review, merge to staging for full integration testing
  4. When QA passes, merge staging → main to ship to production

Running crons against staging

Vercel Cron Jobs only run on production deployments. To test cron jobs against staging:

Database migrations on staging

Always run migrations on staging first. Point DATABASE_URL at the staging project (Supabase dashboard → Project Settings → Database → Connection string → URI), then:
The runner applies each migration and records it in schema_migrations in the same transaction, so the two cannot drift. A failure rolls that migration back and stops; earlier ones stay applied, so you fix the SQL and re-run. The script prints the database host before doing anything — read that line before confirming, so you never apply a staging migration to production.

Baselining an existing database

Production predates this runner: ~80 migrations were applied by hand and almost none were recorded. Run this once per existing database, which marks every migration as applied without executing any of it:
Only correct when the database genuinely already has those migrations. A fresh staging project should be migrated normally instead, not baselined.