> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shikshaos.triverseinfotech.com/llms.txt
> Use this file to discover all available pages before exploring further.

# staging-setup

# Staging Environment Setup

## Overview

`main` → production (`shikshaos.triverseinfotech.com`)<br />`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:

```text theme={null}
migrations/0000_migration_tracking.sql
migrations/0001_ux_polish.sql
migrations/0002_infrastructure.sql
```

### 2. Create the `staging` git branch

```bash theme={null}
git checkout -b staging
git push -u origin staging
```

### 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:

| Variable                        | Value                        |
| ------------------------------- | ---------------------------- |
| `NEXT_PUBLIC_SUPABASE_URL`      | staging project URL          |
| `NEXT_PUBLIC_SUPABASE_ANON_KEY` | staging anon key             |
| `SUPABASE_SERVICE_ROLE_KEY`     | staging service role key     |
| `CRON_SECRET`                   | a different secret from prod |
| `NEXT_PUBLIC_APP_VERSION`       | `staging`                    |

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

```bash theme={null}
git checkout staging
git push origin staging
```

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

## Deploy workflow

```text theme={null}
feature-branch → PR → staging (QA) → merge to main → production
```

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:

```bash theme={null}
curl -H "Authorization: Bearer $CRON_SECRET" \
  https://your-staging-url.vercel.app/api/cron/fee-reminders
```

## Database migrations on staging

Always run migrations on staging first:

```bash theme={null}
# Check status
npx ts-node scripts/migrate.ts --status

# Paste pending SQL into Supabase SQL editor for staging project, then:
# Update schema_migrations manually or re-run the script
```
