TL-M0-20 · The v2 staging Supabase project
Why: v2 needs a staging database of its own, separate from v1 and from production, with no Supabase branching (D5). This step creates the empty project, in Singapore on Postgres 17 (D12), and gives it the local stack's auth settings. It also makes the GitHub environment that holds staging's secrets, usable from main only (D28). Nothing is pushed here: the schema, seed and E2E logins arrive in BE pack F, the next row (#22).
ID TL-M0-20 · Level L0 · Run order row 31 · Issue #21
An empty Supabase project named opleet-v2-staging exists in Singapore on Postgres 17, signing tokens with an asymmetric key. Its sign-up is off, as on the local stack. Its keys are in your password manager, and the git-ignored .env.staging holds what pack F needs. The GitHub environment staging exists and only main can use it.
Before
Section titled “Before”- Row 22, BE pack E (#14), is Done.
- You have chosen the Supabase organization for v2's projects, staging now and production later.
- On the Free plan, a project pauses after a week without activity, and an organization can have only two active projects.
- On the Pro plan, a Micro project costs about $10 a month.
- Recommended: a Pro organization. Staging must stay up for the Vercel deployment (TL-M0-21) before the nightly job keeps it busy. Below, <SUPABASE_ORG> is the organization you chose.
- A password manager is open, with a new entry ready for "Opleet v2 staging".
- You are in ~/opleet-v2/opleet on main, up to date, and
git status --shortprints nothing.
1 · Create the project
Section titled “1 · Create the project”In the browser: supabase.com/dashboard › New project.
- Organization: <SUPABASE_ORG>
- Project name: opleet-v2-staging
- Database password: Generate a password, then copy it into the password manager entry as the database password. It appears below only as <STAGING_DB_PASSWORD>, and you type it only at a CLI prompt.
- Region: Southeast Asia (Singapore)
- Compute size, on Pro: Micro
- Security options: leave the defaults.
Create the project, and wait until the dashboard says it is ready.
2 · Note the project ref
Section titled “2 · Note the project ref”The project ref is the 20 lowercase letters and digits in the dashboard's address, after /project/. It is not a secret. Below it appears as <STAGING_PROJECT_REF>. Put it in the password manager entry too.
In the dashboard: Project Settings › Infrastructure. Check that the Postgres version starts with 17.
3 · Auth settings, by hand, to match the local stack
Section titled “3 · Auth settings, by hand, to match the local stack”These match supabase/config.toml from BE pack A. Leave every other setting at its default.
- Authentication › Sign In / Providers:
- "Allow new users to sign up": off (local: enable_signup = false).
- "Allow anonymous sign-ins": off.
- "Allow manual linking": off.
- Save.
- Authentication › Sign In / Providers › Email:
- "Confirm email": off (local: enable_confirmations = false). Staff are invited by an admin, and the E2E logins are made by a script.
- Save.
- Authentication › URL Configuration: leave Site URL as it is. TL-M0-21 sets it to the Vercel deployment's address.
Password policy, session length and the email sender are OQ12 and stay at their defaults until it is decided.
4 · Log the CLI in to Supabase and see the project
Section titled “4 · Log the CLI in to Supabase and see the project”pnpm supabase loginpnpm supabase projects listThe login opens a browser and keeps its access token in your Mac's keychain, outside the repository.
5 · The keys: password manager first, then .env.staging
Section titled “5 · The keys: password manager first, then .env.staging”In the dashboard: Project Settings › API Keys. Copy the publishable key (it starts with sb_publishable_) and the secret key (it starts with sb_secret_) into the password manager entry. v2 uses only these two (D13). If a Legacy tab shows anon or service_role keys, don't copy them.
Create .env.staging with the right permissions, then open it in TextEdit. The secret key is pasted into the file, never typed into the terminal, so it stays out of your shell history.
touch .env.stagingchmod 600 .env.staginggit check-ignore -v .env.stagingopen -e .env.stagingIn TextEdit, paste these three lines with your values, save, and close:
SUPABASE_URL=https://<STAGING_PROJECT_REF>.supabase.coSUPABASE_SECRET_KEY=<STAGING_SECRET_KEY>STAGING_PROJECT_REF=<STAGING_PROJECT_REF>6 · The GitHub environment for staging, usable from main only
Section titled “6 · The GitHub environment for staging, usable from main only”Staging's secrets will live here (D28). No secret goes in yet: the nightly rehearsal job adds its own, in the data phase. Replace <STAGING_PROJECT_REF> before you run this block.
gh api -X PUT repos/Opleettop/monorepo/environments/staging --input - <<'EOF'{ "deployment_branch_policy": { "protected_branches": false, "custom_branch_policies": true } }EOFgh api -X POST repos/Opleettop/monorepo/environments/staging/deployment-branch-policies -f name=main -f type=branchgh variable set STAGING_PROJECT_REF --env staging --body "<STAGING_PROJECT_REF>"Expect
Section titled “Expect”- Block 1: the dashboard opens the new project's home page once it is ready, after a minute or two.
- Block 2: a Postgres version starting with 17.
- Block 4: "You are now logged in", then a table that lists opleet-v2-staging with your project ref and the region Southeast Asia (Singapore).
- Block 5: git check-ignore prints a line ending in .env.staging, from .gitignore. TextEdit opens an empty file.
- Block 6:
- The first command prints the environment as JSON, with "custom_branch_policies": true.
- The second prints a policy named main.
- The third prints "✓ Created variable STAGING_PROJECT_REF for Opleettop/monorepo".
Replace <STAGING_PROJECT_REF> first.
curl -s https://<STAGING_PROJECT_REF>.supabase.co/auth/v1/.well-known/jwks.json | grep -o '"alg":"[A-Z0-9]*"'grep -c '=' .env.staginggit status --shortgh api repos/Opleettop/monorepo/environments/staging/deployment-branch-policies --jq '.branch_policies[].name'- The jwks line prints
"alg":"ES256"(or RS256): the project signs tokens with an asymmetric key, whichgetClaims()needs (D13). The endpoint is public; it prints no secret. - grep prints 3.
- git status prints nothing: .env.staging is ignored.
- The last command prints main.
If it fails
Section titled “If it fails”- The jwks line prints nothing, or HS256: the project signs with the old shared secret. In the dashboard, open Project Settings › JWT Keys and look for a migration offer. Stop, and paste what that page shows into #21 before changing anything.
- Southeast Asia (Singapore) isn't offered, or the Postgres version isn't 17: stop before creating the project, and ask in #21.
- git status shows .env.staging: don't commit. Check that .gitignore has a line
.env.staging, then paste the output ofgit check-ignore -v .env.staging. - Block 6 errors with 404 or 422: paste the output. The environment can be made again; nothing else depends on it yet.
- The project, while it is still empty: delete it in the dashboard, under Project Settings › General › Delete project. Once pack F has pushed to it, ask zuki first.
- The environment:
gh api -X DELETE repos/Opleettop/monorepo/environments/staging. - The local file:
rm .env.staging.
Log each run as a comment on #21: the date, what you ran, and the output that mattered. Never paste a key or the database password.