Skip to the lesson
CivOps AI Academy · F18Deploy and Run: Migrations on Merge, Previews, Rollback, Backups and the Runbook
0%

Chapter 1 · Session 11

Production comes only from main

There are tables, test data, access rules, sign-in and the ten quality checks, but no screens yet. That makes this the cheapest moment to make deploys safe: nothing the plant uses can break while you set it up, and every screen from Session 12 on is tested where it will run.

25 min2 stepsRules first, then previews

By the end of this chapter you can

  • Say what changes in this session, and why it comes before the first screen.
  • Check that every production deployment was built by Vercel from main, and write the rule down for Claude Code.
  • Point every preview at the development project, so a half-finished change can only touch made-up data.

Why deploys come before screens

Until now you have applied each migration to the live database yourself, after the merge, as Session 5 showed. That works while you remember. We did not: our platform's production database fell nine migrations behind main, the oldest seven weeks old, and pages that worked in preview failed in production with database errors, days after the merge. The cure is to make the deploy apply migrations and stop if one fails, and to check every day that production has every migration main has [1].

Doing it now, in week 3, costs one session while nothing depends on the platform. Doing it after the operator screens are live means learning it during an outage.

The deployment pipelineEight stages from branch to live: branch, pull request, checks, preview, review, merge, migrate and live. Every stage runs by itself except the review; a red check or a rejected review sends the change back. One path for every change, whether you or Claude Code made itBranchone change01Pullrequestsays why02Checksbuild, tests,schema, clamps03Previewdevelopmentdata04Reviewa person readsit05Mergemain only06Migratedev, thenproduction07LiveVercelpromotes08A red check or a rejected review sends the change backStages 7 and 8 are new in Session 11Stage 5 is the only one that needs you
The path every change takes from this session on. Stages 1 to 6 you already have. Session 11 adds 7 and 8: migrations applied on merge, and production promoted only when they succeed.
Until this sessionFrom this session
Live database changesYou run npx supabase db push after each mergeThe deploy workflow applies them on merge; you never run db push for production again
PreviewsTalk to the production project (the integration copied its keys everywhere)Talk to the development project, with made-up data only
ProductionVercel builds main and makes it live at onceVercel makes it live only when the deploy workflow is green
Knowing production is currentYou remember to checkA daily check compares production with main and opens an issue
BackupsNone of your ownNightly, encrypted, kept off the platform, and restored once
When it breaksImprovisedocs/runbook.md, with drills written in its log
Step 1

Production comes only from main: check it, and write it down

10 minutes

Why

Production must be built by Vercel from main, after a reviewed merge, and nothing else. We hit the alternative: a deploy run from a laptop built on the laptop, picked up its local settings and sent production to a database at localhost; three live pages failed while the same commit built from GitHub worked. Writing the rule into CLAUDE.md and the deny list makes it hold for every later session and every agent, without you repeating it.

Do this

Open

https://vercel.com/acme-ops/acme-platform/deployments

Filter by Production. Every row should show the branch main and a commit message. A production row with no commit is a deployment from someone's computer.

Paste into Claude Code
Read CLAUDE.md, .claude/settings.json and docs/KEYS.md. On a new branch deploy/rules:

1. In CLAUDE.md, add a section "Deploys and the live database":
   - Production is built only by Vercel from main, after a merged pull request. Never run vercel deploy, vercel --prod, vercel promote or vercel rollback, and never deploy from this computer. If you think a deploy is needed, tell me.
   - Migrations reach the development and production databases only through the deploy workflow on merge (added in this session). Never run supabase db push, supabase db reset or supabase link against either project, and never ask for a database password.
   - A red check counts only if it ran on the branch's latest commit. Before diagnosing one, say which commit it ran on and how far behind main that commit is. If it is behind, merge origin/main into the branch (no rebase, no force push), push, and wait for the new checks. Never re-run old runs.
2. In .claude/settings.json, keep every existing deny rule and add denies for vercel deploy, vercel promote, vercel rollback and supabase link, each in both the npx and the plain form.
3. Change nothing else.

Open a pull request titled "Deploy rules", wait for every check to finish, and tell me the result in plain words.

You will see recreated screen

vercel.com/acme-ops/acme-platform/deployments
AllProductionPreview
1
DeploymentStatusSourceCreated
CurrentReadymain · Clamps: required checks and CODEOWNERS (#31)2d ago
Readymain · Sign-in that denies by default (#27)5d ago
Readymain · Access rules from the matrix (#24)8d ago
Vercel's deployments, filtered to production. Every one names main and a commit: built from GitHub, never from a computer.
  1. Each row: main, and the title of the pull request it came from. A row that says it was deployed with the command line, or shows no commit, needs explaining before you go on.

You will see recreated screen

claude — acme-platform
⏺ Write(CLAUDE.md)
+## Deploys and the live database
+- Production is built only by Vercel from main, after a merged pull request.
+ Never run vercel deploy, vercel --prod, vercel promote or vercel rollback.
+- Migrations reach the databases only through the deploy workflow on merge.
+ Never run supabase db push, db reset or link. Never ask for a database password.
1
⏺ Write(.claude/settings.json)
  "Bash(npx supabase db push:*)", "Bash(npx supabase db reset:*)",
+ "Bash(npx vercel deploy:*)", "Bash(vercel deploy:*)", "Bash(npx vercel promote:*)",
+ "Bash(npx vercel rollback:*)", "Bash(npx supabase link:*)", "Bash(supabase link:*)",
2
⏺ Bash(gh pr checks --watch)
⎿ ci pass · schema pass · clamps (10 jobs) pass
⏺ Pull request #33 adds the deploy rules to CLAUDE.md and six new deny rules. Nothing else changed. All checks are green on the latest commit.
Claude Code adds the rules, waits for the checks, and reports.
  1. The rule in words, for every future session.
  2. The same rule, enforced: Claude Code cannot run these commands even if asked.

Check it worked

Every production row in Vercel came from main. Pull request Deploy rules is green on its latest commit, changes only CLAUDE.md and .claude/settings.json, and owner two has approved and merged it.

Fastest path

When Claude Code asks to run gh pr checks --watch, choose the "don't ask again" option: it only reads the checks, and every prompt in this session ends with it.

If it goes wrong

A production deployment has no commit, or says it was deployed from the command line

Someone deployed from a computer. Open the newest production deployment that came from main and use its menu to make it the live one again (Promote, or Instant Rollback if it is older). Then find out who deployed and why: a computer sends its local settings and unsaved files with it. From now on the deny rule stops Claude Code doing it.

The Vercel build fails with "Reached heap limit", or "Deployment has failed" on several pull requests at once

We hit this: the build ran out of memory, and every pull request showed it as a different failure. Say: Open the Vercel build log for this deployment and tell me the exact error. If it ran out of memory, find where the build's memory limit is set, tell me the peak the build reached, raise the limit to at least 512 MB above that peak, and add a test that fails if the limit is ever set below peak plus 512 MB. If this branch is behind main, merge main first and check whether main already raised it.

A check is red for a reason that has nothing to do with this change, or its logs have expired

The verdict is probably about an old commit. Agents have chased such checks for hours, and re-running old runs once sent us 113 failure emails in a day. Say: Before diagnosing this red check: tell me which commit it ran on, how far that commit is behind main, and whether main has fixed anything since. If it is behind, merge origin/main into the branch (no rebase, no force push), push, and wait for the new checks. Only diagnose what is still red after that.

Step 2

Previews use the development project

15 minutes

Why

Since Session 1, the Supabase integration has copied the production project's keys into every Vercel environment, so every preview talks to the production database. With no screens yet that has done no harm. From Session 12, previews save records, and a half-finished change tried on a preview would write into the plant's real data. Pointing previews at the development project from Session 6 means anything tried on a preview lands on made-up data, and real data never leaves production.

Do this

Open

https://supabase.com/dashboard/project/abcdefghijklmnopqrst/settings/integrations

The production project's integrations. Open the Vercel connection to acme-platform and limit the environments it syncs to Production only. Save.

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/settings/integrations

The development project's integrations. Under Vercel, add a project connection to acme-platform in the acme-ops team, syncing Preview and Development only.

Open

https://vercel.com/acme-ops/acme-platform/settings/environment-variables

Check by name: each Supabase variable now has one row for Production and one for Preview and Development. Values stay hidden; nobody typed them.

Then make it visible on the site, so you never have to guess which database a deployment uses:

Paste into Claude Code
Read node_modules/next/dist/docs/ for how this version of Next.js reads environment variables, then the /status page from Session 3.

On a new branch status/database, change the /status page so it also says which Supabase project this deployment talks to: "production" when NEXT_PUBLIC_SUPABASE_URL contains abcdefghijklmnopqrst, "development" when it contains tsrqponmlkjihgfedcba, and "unknown" otherwise. Never show the address or any key. Add a test for each of the three answers.

Open a pull request titled "Status shows the database", wait for every check and for the Vercel preview, and give me the preview link.

You will see recreated screen

vercel.com/acme-ops/acme-platform/settings/environment-variables
GeneralDomainsEnvironment VariablesGitDeployment Protection
1
KeyValueEnvironments
NEXT_PUBLIC_SUPABASE_URL••••••••Production
NEXT_PUBLIC_SUPABASE_URL••••••••Preview, Development
NEXT_PUBLIC_SUPABASE_ANON_KEY••••••••Production
NEXT_PUBLIC_SUPABASE_ANON_KEY••••••••Preview, Development
The variables after the change: the same names, a different project per environment. The exact names depend on the integration's version.
  1. Two rows per name: one per project.
  2. Both kept in step by the integration, so rotating a key in either project updates Vercel.

You will see recreated screen

acme-platform-git-status-database-acme-ops.vercel.app/status
Acme Bottling platform — Cleveland
Builda41c9e2 · 2026-10-21 10:14
Databasedevelopment1
The preview of the pull request: the status page now says which database it uses.
  1. On a preview: development. On https://acme-platform.vercel.app/status after the merge: production. Anything else means stop and look.

Check it worked

The preview's /status says development. After owner two approves and you merge, https://acme-platform.vercel.app/status says production.

Fastest path

Do the two integration pages and the Vercel check before pasting the prompt: Claude Code's preview then proves the switch worked in the same pull request.

If it goes wrong

The integration page offers no choice of environments, or Vercel will not let you edit the variables

Integration screens change. Do not delete the production connection. Ask in office hours, or type the development project's address and publishable key into the Preview rows on Vercel's page yourself, copied from the development project's API Keys page: the value only, no quotes, no NAME=.

The preview build stops with "TypeError: Invalid URL", with the value hidden

We hit this: an address pasted with quotes, a NAME= prefix or a space. Open the variable in Vercel and paste the value again, on its own. The start-up check from Session 10 should name which variable is wrong without printing it; if it did not, say: The start-up check did not catch a malformed Supabase address. Add a test that feeds it an address with quotes, a NAME= prefix and a space, and expects each to be named.

Something saves on your computer but is gone on the preview or the live site

On Vercel the app's own folders are read-only and each server copy is separate, so writing a file works only on your computer. We hit this. Say: Find every place the app writes a file to disk (fs.writeFile, fs.appendFile, anything under public/ or the project folder). Move each to a database table or to Supabase Storage, and add a test that fails if new code writes into the project folders.

The preview asks me to sign in to Vercel

That is Vercel's Deployment Protection: previews are for your team only. Leave it on, sign in, and carry on.

Knowledge check

Why do previews use the development project from this session on?

Knowledge check

A production deployment in Vercel's list shows no commit and was made from the command line. What does it tell you?

References

  1. Supabase Docs: Managing environments (migrations from GitHub Actions). https://supabase.com/docs/guides/deployment/managing-environments
  2. Vercel Docs: Environments (local, preview, production). https://vercel.com/docs/deployments/environments
  3. Vercel Docs: Deploying from Git. https://vercel.com/docs/deployments/git
  4. Supabase Docs: Vercel integration. https://supabase.com/docs/guides/integrations/vercel-marketplace
  5. Claude Code docs: Settings and permission rules. https://code.claude.com/docs/en/settings

Chapter 2 · Session 11

Migrations on merge, and a daily check

You type five secrets into GitHub. One prompt writes the workflow that applies migrations on every merge, development first, and the check that proves every morning that production matches main. Then production learns to wait for the workflow, and you fire the alarm once to prove it reaches you.

40 min4 stepsNo more db push by hand

By the end of this chapter you can

  • Type the deploy secrets into GitHub yourself and list them by name in docs/KEYS.md.
  • Have Claude Code write deploy.yml and prod-freshness.yml in one pull request.
  • Make Vercel wait for the deploy workflow, so a failed migration stops the deploy.
  • Fire the freshness alarm on purpose and see it reach both owners.

What the deploy does on every merge

What happens on mergeOn every merge to main the deploy workflow checks its secrets, applies migrations to the development project and then to production; Vercel promotes the new build only when the workflow is green. If any step fails the deploy stops and production keeps the previous build and schema. A daily freshness check compares production's migrations with main. .github/workflows/deploy.yml, on every merge to mainMerge to mainapproved, checks greenCheck the secretspresent and the rightshapeMigrate devdevelopment goes firstMigrate productiononly if developmentworkedVercel promotesonly when deploy isgreenAny step fails: the deploy stopsproduction keeps the previous build and schema; fix forward with a new pull requestEvery morning: the freshness checkcompares the migrations applied in production with main, and opens an issue if theydiffer
On merge. Development gets each migration first, with its made-up data; production only if that worked; and Vercel makes the new build live only when the whole workflow is green. Every morning a separate check confirms production still matches main.

This follows Supabase's own pattern for deploying migrations from GitHub Actions: the workflow links to the project with an access token and the database password, both kept as GitHub secrets, and runs supabase db push [1][2]. A failure stops the job, and everything after it.

One rule keeps this safe. For a minute during every deploy, and for as long as you like after a rollback, the old code runs against the new schema. So every migration must work with the code that is already running: add a column first, start using it in a later change, and remove the old one only when nothing reads it. This is called expand and contract [3]. Adding is safe in one step; renaming, dropping or making a column required is not.

Step 3

Type the secrets into GitHub yourself

15 minutes

Why

The deploy logs in to Supabase from GitHub's computers, so GitHub needs the keys. Typed by you into GitHub's secrets page, they are encrypted, never shown again, and never pass through a chat or a file. A secret that is missing or wrong is the commonest failure here: on our platform a secret that was never created resolved to an empty string, so nothing complained and nothing worked. Step 4's workflow checks each one's shape before it uses it.

Do this

First the two values that do not exist yet. Each goes straight into the password manager, never anywhere else:

Open

https://supabase.com/dashboard/account/tokens

Generate new token. Name: github-actions-acme-platform. Copy it straight into the password manager as Supabase: access token for GitHub Actions. It is shown once.

In the password manager, generate a 32-character password and save it as Backup passphrase: acme-platform. Every backup from chapter 3 is locked with it: without it, no backup can be opened.

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba

The development project. Press Connect at the top and copy the Session pooler connection string. It contains [YOUR-PASSWORD]: you replace that with the development project's password inside GitHub's form below, not in a file or a chat.

Then add five repository secrets, one at a time:

Open

https://github.com/acme-ops/acme-platform/settings/secrets/actions

New repository secret for each row below. Paste the value only: no quotes, no NAME=, no spaces at either end.

Name (type exactly)Value, from
SUPABASE_ACCESS_TOKENPassword manager: Supabase access token for GitHub Actions
PRODUCTION_PROJECT_IDabcdefghijklmnopqrst (not secret, but kept here so no workflow has it written in)
PRODUCTION_DB_PASSWORDPassword manager: Supabase: acme-platform-prod database password
DEV_DB_URLThe development project's Session pooler string, with its password in place of [YOUR-PASSWORD]
BACKUP_PASSPHRASEPassword manager: Backup passphrase: acme-platform
Key or secretWhat it unlocksWhere it livesWho holds itNever
SUPABASE_ACCESS_TOKENActs as you in Supabase, in every organisation you belong toGitHub Actions secret; password managerpat@acme.com created it; sam@acme.com can replace itNever in a file, a chat or a log; never without an expiry note in docs/KEYS.md
PRODUCTION_DB_PASSWORDFull control of the production databaseGitHub Actions secret; password managerpat@acme.com, sam@acme.comNever on a laptop's command line again after this session
DEV_DB_URLFull control of the development database (made-up data only)GitHub Actions secretpat@acme.com, sam@acme.comNever pointing at the production project
BACKUP_PASSPHRASEOpens every backupGitHub Actions secret; password managerpat@acme.com, sam@acme.comNever only in GitHub: lose it there and every backup is unreadable

You will see recreated screen

github.com/acme-ops/acme-platform/settings/secrets/actions
GeneralRulesActionsSecrets and variablesEnvironments
Actions secrets and variables
SecretsVariables
1
Repository secretsLast updated
BACKUP_PASSPHRASEnow
DEV_DB_URLnow
PRODUCTION_DB_PASSWORDnow
PRODUCTION_PROJECT_IDnow
SUPABASE_ACCESS_TOKENnow
New repository secret2
GitHub's Actions secrets after the five are added. Names only: nobody, including you, can read a value back.
  1. Exactly these five names. A typo in a name is a missing secret to the workflow.
  2. One at a time: name, value, Add secret.

Check it worked

The page lists exactly the five names, spelled as in the table. The token and the passphrase are in the password manager. Nothing was pasted anywhere else.

Fastest path

Put the password manager and GitHub's page side by side: copy one value, paste, save, next. Five minutes, and no value ever passes through Claude Code.

If it goes wrong

DEV_DB_URL still contains [YOUR-PASSWORD], or the password has characters such as @, # or /

We hit this: a database address refused as copied, because of a placeholder, quotes or a character that must be encoded. The development project holds only made-up data, so the quick fix is safe: reset its password (Project Settings, Database) to one of letters and digits only, save it in the password manager, and type the string into the secret again with Update.

I pasted NAME=value, or the value with quotes

Open the secret, choose Update and paste the value on its own. We hit exactly this in the Academy: a key's value was the variable's own name. Step 4's workflow checks each secret's shape and names any that is wrong, without printing it.

The access token is mine. What happens when I leave?

A Supabase access token acts as the person who made it. Write who holds it in docs/KEYS.md (Step 4 does), and make replacing it part of any owner leaving: owner two generates a new one and updates the secret. The runbook (Step 10) lists the steps.

Claude Code asks me for one of these values

Answer: No. Secrets are typed by a person into GitHub's settings page. Use the secret's name.

Step 4

One prompt: the deploy workflow and the daily freshness check

15 minutes

Why

The workflow that applies migrations and the check that proves it worked belong in one pull request, so the safety net arrives with the change. One complete prompt also replaces the round trips it takes to add each part as you think of it: the order of jobs, what happens on failure, the secret checks, the alarm and the key register are all in it. Telling Claude Code to read Supabase's guide first stops it inventing a workflow from memory.

Do this

Paste into Claude Code
Read CLAUDE.md, docs/KEYS.md, supabase/ and .github/. Read Supabase's guide "Managing environments" (https://supabase.com/docs/guides/deployment/managing-environments) before writing anything.

On a new branch deploy/migrations-on-merge:

1. .github/workflows/deploy.yml, named "deploy", running on every push to main and by hand (workflow_dispatch), one run at a time (a concurrency group that never cancels a running deploy):
   - job "secrets": check that SUPABASE_ACCESS_TOKEN, PRODUCTION_PROJECT_ID, PRODUCTION_DB_PASSWORD and DEV_DB_URL are set and have the right shape (the token starts with sbp_; the project id is 20 lower-case letters; DEV_DB_URL starts with postgresql://, does not contain [YOUR-PASSWORD] and does not contain the production project id). If one is wrong, name it and say what is wrong; never print it.
   - job "migrate-dev", after "secrets": apply pending migrations to the development project with supabase db push --db-url.
   - job "migrate-production", after "migrate-dev": supabase link to PRODUCTION_PROJECT_ID, print supabase migration list, then supabase db push. If anything fails, the job fails and nothing after it runs.
   - Use the Supabase CLI through supabase/setup-cli, pinned to one version. Never echo a secret.

2. .github/workflows/prod-freshness.yml, named "prod-freshness", every day at 06:10 UTC and by hand: for production and for development, compare the migrations applied with the files in supabase/migrations on main (supabase migration list and supabase db push --dry-run; it must never apply anything). If either project is missing a migration, or has one main does not have, fail and open a GitHub issue titled "Production is behind main" that lists the versions, assigned to both owners. Give it a manual input fire_alarm that takes the failure path on purpose without touching either database. The issue step must work without a copy of the repository: use gh with --repo and give the job permission to write issues.

3. .github/CODEOWNERS: require review from pat@acme.com and sam@acme.com (CODEOWNERS accepts the email on each GitHub account) for .github/workflows/.

4. docs/KEYS.md: add the five Actions secrets by name (SUPABASE_ACCESS_TOKEN, PRODUCTION_PROJECT_ID, PRODUCTION_DB_PASSWORD, DEV_DB_URL, BACKUP_PASSPHRASE): what each unlocks, where it lives, who holds it, never a value. Note that the access token belongs to the person who made it.

5. CLAUDE.md, under "Deploys and the live database": deploy.yml now applies migrations on merge; nobody runs supabase db push by hand for production.

Do not run either workflow, do not link to or change any Supabase project, and do not read any .env file. Push, open a pull request titled "Migrations on merge", wait for every check to finish, and tell me in plain words what each new workflow will do, which secrets it reads by name, and what happens when a migration fails.

You will see recreated screen

claude — acme-platform
☒ Read Supabase guide: Managing environments
☒ Write .github/workflows/deploy.yml
☒ Write .github/workflows/prod-freshness.yml
☒ Update CODEOWNERS, docs/KEYS.md, CLAUDE.md
☐ Push, open the pull request, wait for checks
1
⏺ Write(.github/workflows/deploy.yml)
+ migrate-production:
+ needs: migrate-dev
+ runs-on: ubuntu-latest
+ env:
+ SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
+ SUPABASE_DB_PASSWORD: ${{ secrets.PRODUCTION_DB_PASSWORD }}
+ steps:
+ - run: supabase link --project-ref "${{ secrets.PRODUCTION_PROJECT_ID }}"
+ - run: supabase migration list
+ - run: supabase db push
2
⏺ Bash(gh pr checks --watch)
⎿ ci pass · schema pass · clamps (10 jobs) pass
⏺ Pull request #35 is green. On every merge to main, deploy checks the four secrets' shapes, applies new migrations to the development project, then to production. If any step fails, the jobs after it do not run, so production keeps its current schema. Every morning prod-freshness compares both projects with main and opens an issue for both owners if they differ. It reads secrets by name only; I have not seen any value. Owner review is now required for any change to .github/workflows/.3
Claude Code reads Supabase's guide first, writes the two workflows, and reports in plain words after the checks are green.
  1. The plan, in the order the prompt gave.
  2. Secrets by name only. The values arrive on GitHub's computer when the job runs, hidden in logs.
  3. Read this summary against the prompt: four jobs in order, what failure does, the alarm, owner review.

Check it worked

Pull request Migrations on merge is green on its latest commit; the summary names the jobs secrets, migrate-dev and migrate-production in that order; docs/KEYS.md lists five secret names and no values; GitHub has asked owner two for a review because of CODEOWNERS.

Fastest path

The last paragraph of the prompt (do not run it, wait for the checks, report in plain words) is what turns this into one round trip. The first run happens in Step 5, when you are watching.

If it goes wrong

Claude Code says it needs the database password, or wants to run the workflow to test it

Say: No. The workflow runs on GitHub with the secrets I typed. Its first run is the merge, and I will watch it. The deny rules from Step 1 stop it linking to a project or pushing to a database anyway.

It says done, but the pull request shows a red check

Say: The checks on the pull request are red. Run gh pr checks, read the failed log, fix the cause and wait for green before you report. We trust the check on GitHub, never the summary.

Owner two cannot approve: review is required from a code owner who is not listed

CODEOWNERS names people by their GitHub account. Say: CODEOWNERS does not match owner two's GitHub account. Use their GitHub user name, which I will tell you: <user name>.

Step 5

Make production wait for the deploy, merge, and watch it run

10 minutes

Why

Vercel builds main the moment it changes, at the same time as the deploy workflow runs. Without a link between them, new code can go live before its migration has run, or stay live after the migration failed. Vercel's deployment checks make a production build wait for named GitHub checks before it goes live: if the deploy is red, the plant keeps the previous version. After this step you no longer run db push by hand for production, and your computer is pointed at the development project so an old habit cannot reach real data.

Do this

Owner two approves pull request Migrations on merge; merge it. Then watch the first run:

Open

https://github.com/acme-ops/acme-platform/actions/workflows/deploy.yml

The run for your merge. Open it and wait for three green jobs.

Then tell Vercel to wait for it:

Open

https://vercel.com/acme-ops/acme-platform/settings

In the project's settings, open Deployment Checks, add a check, and choose deploy / migrate-production from GitHub. It is listed once the workflow has run once. Save.

Finally, point the Supabase tool on your computer at the development project. It asks for the development project's password: copy it from the password manager.

Terminal or PowerShell (not inside Claude Code)
cd ~/code/acme-platform && git switch main && git pull && npx supabase link --project-ref tsrqponmlkjihgfedcba

You will see recreated screen

github.com/acme-ops/acme-platform/actions/runs/1184
deploy · Migrations on merge (#35)
2
JobResultTime
secrets✓ 4 secrets present and well formed6s
migrate-dev✓ Remote database is up to date.38s
migrate-production✓ Remote database is up to date.41s
supabase migration list
   Local          | Remote         | Time (UTC)
   20261016091500 | 20261016091500 | 2026-10-16 09:15:00
   20261017140200 | 20261017140200 | 2026-10-17 14:02:00
The first deploy run. With no new migration in this merge, both databases report they are up to date: the point is that it ran, in order, with the secrets you typed.
  1. Green, from a push to main, never from a computer.
  2. Development first, then production. A red line here would stop everything below it.

You will see recreated screen

vercel.com/acme-ops/acme-platform/settings/deployment-checks
GeneralDomainsEnvironment VariablesGitDeployment Checks
Deployment Checks
Production deployments are promoted only when these checks pass.
1
CheckSource
deploy / migrate-productionGitHub Actions
Save
Vercel's deployment checks: production waits for the migration job.
  1. The one check that matters: production waits until migrations have been applied.

Check it worked

The deploy run is green with three jobs; the migration list in its log shows the same versions under Local and Remote; Vercel's deployment checks list deploy / migrate-production; npx supabase migration list on your computer now shows the development project. You do not run npx supabase db push for production again.

If it goes wrong

migrate-production failed

The deploy stopped: production keeps its previous build and schema, which is what you want. Say: The deploy workflow failed in migrate-production. Read its log and tell me in plain words which migration failed, why, and whether anything was applied. Do not touch either project. Propose the fix as a new migration on a new branch. Never edit an applied migration and never apply anything by hand. When the fix merges, the deploy runs again by itself.

Remote migration versions not found in local migrations directory

The live database has a migration main does not: someone changed it outside the files, or an applied file was renamed or deleted. Do not force anything. Say: The deploy says remote migration versions are not in the local directory. Explain in plain words which versions differ and what each did, without changing any project. Then decide with owner two.

The job cannot connect: network is unreachable, or an address full of colons

GitHub's machines do not use the newer kind of internet address (IPv6), and a direct database address may need it. Say: The deploy cannot reach the database from GitHub Actions. Use the connection Supabase recommends for IPv4-only clients (the session pooler), following Supabase's guide, without printing any address.

There is no Deployment Checks page in the project's settings

Vercel renames pages from time to time: search the settings for checks. If it is not there, ask in office hours. Until it is set, open the deploy run after each merge and check it is green before you tell anyone a change is live.

A production deployment shows Canceled

A newer merge replaced it within a minute, so Vercel canceled the older build. We spent hours on this before learning it: a canceled deploy that a newer ready one replaced is not a failure.

Step 6

Fire the alarm once, on purpose

5 minutes

Why

A check that fails without anyone hearing is worse than no check, because everyone believes it is watching. We hit this: a nightly test caught a real production fault ten nights running, but the step that opens an issue had no copy of the repository and died, so nobody heard. Firing the alarm on purpose once proves the issue really reaches both owners' inboxes.

Do this

Open

https://github.com/acme-ops/acme-platform/actions/workflows/prod-freshness.yml

Run workflow on main, set fire_alarm to true, and run it. When the issue arrives, run it again with fire_alarm false.

You will see recreated screen

github.com/acme-ops/acme-platform/issues/36
Production is behind main #36
Opened by github-actions · prod-freshness (alarm drill: fire_alarm = true)1
Assigneespat@acme.com, sam@acme.com2
Production: no differences (drill)
Development: no differences (drill)
This issue was opened on purpose to test the alarm.
The issue the alarm opens, assigned to both owners. Both of you should get the email.
  1. Opened by the workflow, not by a person: the alarm path works.
  2. Both owners. An alarm only one person hears fails when that person is away.

Check it worked

Both owners received the issue email. The second run, with fire_alarm false, is green and says production and development match main. Close the drill issue with a comment: Alarm drill, worked.

If it goes wrong

The run failed but no issue appeared

That is the exact fault we had. Say: prod-freshness failed but opened no issue. Read the failed step's log, fix the issue step so it works without a copy of the repository (gh with --repo, permission to write issues), and tell me what to click to fire it again. Do not run it yourself. Then fire it again yourself.

The check is red every morning and nobody looks

Any check that has been red for two mornings without an open issue is itself a defect. Put the freshness check on the runbook's daily list (Step 10).

A real (not drill) issue says production is behind main

Open the deploy run for the last merge: usually migrate-production failed, and Step 5's first fix applies. Once the cause is fixed and merged, the deploy applies what is missing. If nothing new needs merging, run the deploy workflow by hand on main (Run workflow). Never catch up with db push from a computer.

Knowledge check

After this session, who applies a merged migration to the production database?

Knowledge check

The deploy fails in migrate-production. What does the plant see?

References

  1. Supabase Docs: Managing environments (GitHub Actions). https://supabase.com/docs/guides/deployment/managing-environments
  2. Supabase CLI reference: supabase db push. https://supabase.com/docs/reference/cli/supabase-db-push
  3. Martin Fowler: Parallel Change (expand and contract). https://martinfowler.com/bliki/ParallelChange.html
  4. GitHub Docs: Using secrets in GitHub Actions. https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions
  5. GitHub Docs: About code owners. https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
  6. GitHub Docs: Events that trigger workflows (schedule, workflow_dispatch). https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows

Chapter 3 · Session 11

Roll back, back up, restore, and write the runbook

Two things go wrong after a merge: bad code, which Vercel undoes in seconds, and a bad migration, which nothing undoes, so you fix it forward. Then the rarer, worse case: a lost database, restored from a backup you have already restored once. You rehearse all three in daylight and write them into a runbook someone else can follow.

40 min4 stepsEnds with a gate

By the end of this chapter you can

  • Roll the code back in Vercel, undo the rollback, and fix a database change forward with a new migration.
  • Add a nightly, encrypted backup that opens an issue if it fails.
  • Restore that backup into the development project, compare the row counts and time it.
  • Draft docs/runbook.md from the repository and make it true with the drills.

Code goes back; the database goes forward

Vercel keeps every deployment it has built, and the production address points at one of them. Instant Rollback moves that pointer back to an earlier build in seconds, with no rebuild [1]. Two things it does not do: it does not touch the database, and after a rollback new merges stop going live by themselves until you undo it, so a second bad merge cannot undo your rescue [1].

Instant rollbackFour kept deployments, builds 41 to 44. Production pointed at build 44, which broke; it is moved back to build 43 in seconds without a rebuild. The database is not rolled back: a database mistake is fixed forward with a new migration. Every deployment is kept. Production points at one of them.Build 41built Mon 09:12Build 42built Tue 14:03Build 43built Wed 10:47Build 44built Thu 07:30Productionbefore: 44 brokeafter: back to 43 in seconds, no rebuildDatabasestays where it is: fix it forward
Instant rollback. Production points back at the last good build. The database stays where it is, which is why every migration must also suit the previous build.

A migration has no rollback button. Once applied it is history, as Session 5 taught: a mistake in it is corrected by a new migration, through a pull request and the same deploy. That is called fixing forward.

Step 7

Rehearse a rollback: the code goes back, the database goes forward

15 minutes

Why

The first rollback should not happen during an outage with the floor waiting. This drill makes one harmless, visible change to the code and one to the database, then undoes each the right way: the code with Vercel's Instant Rollback, the database with a forward fix. It also gives the deploy workflow its first real migration to apply, so you watch the whole path work end to end.

Do this

Paste into Claude Code
On a new branch drill/rollback:
1. Change the heading of the /status page to "ROLLBACK DRILL".
2. Add a new migration (npx supabase migration new rollback_drill) that only sets a comment on the table lots: 'Rollback drill: wrong on purpose'. Add a pgTAP test that the table lots has a comment.
Change nothing else. Open a pull request titled "Rollback drill", wait for every check, and tell me the result.

Owner two approves; merge. Wait for the deploy run to go green, then open https://acme-platform.vercel.app/status: it says ROLLBACK DRILL. Now roll it back, with a stopwatch running:

Open

https://vercel.com/acme-ops/acme-platform/deployments

Find the production deployment before the drill, open its menu (⋯) and choose Instant Rollback. Confirm. Refresh https://acme-platform.vercel.app/status until the old heading is back; write down the seconds.

Open

https://supabase.com/dashboard/project/abcdefghijklmnopqrst/editor

Open the table lots: its description still says Rollback drill: wrong on purpose. The rollback did not touch the database.

Now fix it forward:

Paste into Claude Code
On a new branch drill/forward-fix:
1. Put the /status heading back as it was before the drill.
2. Add a NEW migration (npx supabase migration new rollback_drill_fix) that sets the comment on lots to 'One row is one lot.' Do not edit the rollback_drill migration: it has been applied to production. Update the test if it needs to.
Open a pull request titled "Forward fix after the drill", wait for every check, and tell me the result.

Merge it and wait for the deploy run. Because production is rolled back, the new build does not go live by itself: in Vercel, choose Undo Rollback on the banner, or Promote on the newest production deployment.

You will see recreated screen

vercel.com/acme-ops/acme-platform/deployments
2
DeploymentStatusSource
Readymain · Rollback drill (#37)
CurrentReadymain · Status shows the database (#34)
Vercel after the rollback: production points at the build before the drill, and a banner says new merges will not go live until you undo it.
  1. The safety catch: until you undo it, a second bad merge cannot replace your rescue.
  2. The drill build is still kept, for study. Production points at the one below it.

You will see recreated screen

claude — acme-platform
⏺ Bash(npx supabase migration new rollback_drill_fix)
⎿ Created new migration at supabase/migrations/20261021153000_rollback_drill_fix.sql
1
⏺ Write(supabase/migrations/20261021153000_rollback_drill_fix.sql)
+comment on table public.lots is 'One row is one lot.';
⏺ Bash(gh pr checks --watch)
⎿ ci pass · schema pass · clamps (10 jobs) pass
⏺ Pull request #38 restores the /status heading and adds one migration that corrects the comment. 20261021141500_rollback_drill.sql is unchanged: it is already applied in production, so the fix is a new file. All checks are green.2
The forward fix: a new migration with a later time. The applied drill migration is untouched.
  1. A new file, a later time.
  2. Read for this sentence. If it says it edited the applied file, stop (see below).

Check it worked

https://acme-platform.vercel.app/status shows the normal heading; Vercel's current production deployment is the forward-fix merge, with no rollback banner; the deploy log's migration list shows both drill migrations under Local and Remote; you have the rollback time in seconds.

If it goes wrong

After the rollback, merges no longer go live

That is by design. Choose Undo Rollback, or Promote on the newest production deployment, once the fix is merged.

Claude Code edited the applied rollback_drill migration instead of adding one

Say: Revert the change to the applied migration. Every change to a live table is a new migration. An edited applied file changes nothing in production and makes a fresh database differ from it.

After a real rollback, the old code fails against the new schema

The migration was not one the previous build could live with. Do not roll back further and do not edit the database by hand: fix forward with a new migration or a code change, through a pull request. From now on, add first and remove later (chapter 2).

Backups: what you are promising

Before choosing a backup, agree two numbers with the supervisors. NIST's contingency planning guide names them [2]: the recovery point objective, how much recent data the plant could lose (and re-key from paper), and the recovery time objective, how long the floor can work without the platform. Back up at least as often as the first; practise restoring faster than the second.

RPO and RTOA timeline drawn to scale: last backup at 22:00, database lost at 02:40, restore starts at 03:10, floor back on at 04:25. The recovery point objective covers the entries lost; the recovery time objective covers the time without the platform. What a backup plan promises, on one night shift (drawn to scale)22:00last backup02:40database lost03:10restore starts04:25floor back onRPO: up to 4 h 40 min of entries lostRTO: 1 h 45 minShrink RPO with more frequent backups; shrink RTO with a practised, timed restore
RPO and RTO on one night. The gap before the failure is data lost; the gap after it is time without the platform.
OptionRecovery pointNotes
Nightly export by GitHub Actions, encrypted, kept as a workflow artifact (this session)Up to 24 hoursYours, tested by you, off the database provider. Inside GitHub's included Actions minutes for a small database
Weekly download of that export to a company file storeUp to 7 daysThe offline copy: the 1 in 3-2-1
Supabase Pro's daily backupsUp to 24 hoursRestored from Supabase's dashboard; the Free plan has no backups you can download [3]. Pro was $25 a month in October 2026; prices change
Supabase point-in-time recoveryMinutesA paid add-on to Pro, for when losing a shift's records is not acceptable [3]
The 3-2-1 backup ruleThree copies of the data, on two different kinds of storage, with one kept away from the platform and offline. 3copies of the dataproduction, the nightly backup, andthe weekly copy2different kinds of storageGitHub's artifact store and a companyfile store1copy kept elsewhereoff the platform, and offlineA copy that ransomware or a mistyped command can reach is not the last copy
The 3-2-1 rule: three copies, two kinds of storage, one away from the platform. CISA's ransomware guide adds that one copy should be offline and encrypted [4].
Step 8

Add the nightly backup

10 minutes

Why

Supabase's own backups live in the same account as the database, so one mistyped command or one stolen login can reach both. A nightly export run by GitHub, encrypted with a passphrase only the owners hold, is a copy you control and can restore anywhere: the files come from PostgreSQL's standard dump tool, not a Supabase format [5]. If it fails, it opens an issue, the same way the freshness alarm does.

Do this

Paste into Claude Code
Read docs/KEYS.md, .github/workflows/deploy.yml and Supabase's guide "Backup and restore using the CLI" (https://supabase.com/docs/guides/platform/migrating-within-supabase/backup-restore).

On a new branch ops/nightly-backup, add .github/workflows/backup.yml, named "backup", every night at 02:40 UTC and by hand:
- check the secrets it needs the same way deploy.yml does, plus BACKUP_PASSPHRASE (at least 24 characters);
- link to the production project and export roles, schema and data with supabase db dump, as the guide shows;
- write counts.txt: the number of rows in each table of the public schema, counted from the data export;
- put the files in one archive and encrypt it with gpg (AES256) using BACKUP_PASSPHRASE; nothing unencrypted is uploaded or printed;
- upload the encrypted file as an artifact named backup-<date>, kept 30 days;
- if any step fails, open an issue "Backup failed" assigned to both owners, the same way prod-freshness does.
Add a line on backups to docs/KEYS.md under BACKUP_PASSPHRASE. Do not run the workflow. Open a pull request titled "Nightly backup", wait for every check, and tell me in plain words what it does each night and where the file goes.

Merge it, then make the first backup now rather than waiting for tonight:

Open

https://github.com/acme-ops/acme-platform/actions/workflows/backup.yml

Run workflow on main. When it is green, the artifact is at the bottom of the run's page.

Every Monday, download the newest artifact into the company file store folder IT gives you: that is the offline copy. The runbook (Step 10) carries the reminder.

You will see recreated screen

github.com/acme-ops/acme-platform/actions/runs/1203
backup · manually run
counts.txt
  sites            1
  equipment        6
  parts           14
  characteristics 41
  lots             0
  memberships      2
  inspections      0
  holds            0
2
ArtifactsSizeExpires
backup-2026-10-21.tgz.gpg38 KBin 30 days
The first backup run. The log shows row counts per table, never data; the only file kept is encrypted.
  1. Green. A red run opens a "Backup failed" issue for both owners.
  2. Encrypted. Anyone with read access to the repository can download it; without the passphrase it is noise.

Check it worked

The run is green, one encrypted artifact is listed, and the log shows a count for each table but no rows. Production still has only reference rows and memberships: no plant records yet.

If it goes wrong

The artifact is downloadable by anyone with read access to the repository

Correct, and the reason it is encrypted. Keep repository access to the people the role matrix allows, and the passphrase in GitHub and the password manager only.

Last night's backup did not run at 02:40

GitHub may delay scheduled runs when it is busy, most often at the start of an hour; 02:40 avoids the worst. If a night has no run at all, run it by hand and check the schedule line in backup.yml.

The passphrase is lost

Every backup locked with it is unreadable. That is why it lives in the password manager too, and why Step 9 restores with it: a restore proves the passphrase you hold is the one that locks the files.

Photos or files attached to records are not in the backup

Database exports do not include Supabase Storage. There are none yet; when a later session adds files, it adds them to the backup.

Step 9

Restore it into the development project, and time it

15 minutes

Why

A backup nobody has restored is only a hope: the day you need it, it is corrupt, slow, or restores to a database the code no longer matches. Restoring is its own skill with its own failures, so you do it once now. Production holds only the reference rows from your migrations and the memberships of the people invited in Session 9, no plant records, so this first restore can go into the development project. Session 23 repeats it as a witnessed drill into a throwaway project, once real records exist.

Do this

Paste into Claude Code
Read .github/workflows/backup.yml and Supabase's guide "Backup and restore using the CLI".

On a new branch ops/restore-drill, add .github/workflows/restore-drill.yml, named "restore-drill", run only by hand, with an input backup_run (empty means the latest successful backup run):
- refuse to start unless DEV_DB_URL is set and does not contain PRODUCTION_PROJECT_ID: this workflow must never be able to write to production;
- download that run's artifact and decrypt it with BACKUP_PASSPHRASE;
- empty the public tables of the development project, then restore the public schema's data from the backup as the guide shows;
- count the rows of each public table in the development project and compare them with counts.txt; fail if any differs;
- print a table (table, rows in backup, rows restored) and the minutes from start to finish.
Never print data or secrets. Do not run the workflow. Open a pull request titled "Restore drill", wait for every check, and tell me in plain words what it does and what it can never do.

Merge it. Start a stopwatch, then run it:

Open

https://github.com/acme-ops/acme-platform/actions/workflows/restore-drill.yml

Run workflow on main, backup_run left empty.

When it is green, open the preview of the Restore drill pull request (previews use the development project): /sign-in must load, and a protected page opened signed out must send you to sign-in. Stop the stopwatch. Then put the development project back to made-up data, as in Session 6: empty the tables and run the seed.

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new

The development project's SQL editor: paste the truncate line and then supabase/seed.sql from GitHub, and run.

You will see recreated screen

github.com/acme-ops/acme-platform/actions/runs/1211
restore-drill · manually run
2
TableRows in backupRows restored
sites11
equipment66
parts1414
characteristics4141
memberships22
Restore finished in 2.6 minutes.3
The restore drill's result: every table's count matches the backup, and the time is written in the log.
  1. The guard ran first: this workflow cannot point at production.
  2. Counts compared table by table, not "it looked fine".
  3. Add the time for the preview check: that total is the number for the drill log.

Check it worked

Every count matches; the preview's sign-in page loads and a protected page refuses you signed out; you have the total minutes; and the development project's Table Editor shows the DEMO rows again after the seed.

If it goes wrong

The workflow refuses: DEV_DB_URL points at production

It is doing its job. Fix the secret (Step 3) so it holds the development project's string. Never weaken the guard to make the drill run.

The restore fails with "relation does not exist" or "column does not exist"

The development project does not match the schema the backup came from: it is behind main. Check the latest prod-freshness run, let the deploy bring development up to date (run deploy by hand on main), then run the drill again. This is one of the ways restores fail on the day, which is why you rehearse.

A count differs

Do not sign the drill off. Say: The restore drill's counts differ for <table>. Explain why from the run's log without changing any project, and propose a fix to the backup or the restore.

A protected page shows data to a signed-out visitor on the preview

Stop. Sign-in or the access rules (Sessions 8 and 9) are not doing their job. Open an issue, tell owner two, and merge nothing else until the failing test exists and passes.

The drill took longer than your recovery time objective

Write the real number down anyway: it is the most useful line in the runbook. Then decide with the supervisors whether to restore faster (Supabase Pro's own backups) or plan a longer paper fallback.

Runbook anatomyEight sections of the runbook kept in the repository: what it is, who to call, deploy, roll back the code, fix a migration forward, restore a backup, known problems and a drill log. docs/runbook.md · kept in the repository, printed for the second ownerWhat it isaddress, repository, projects,ownersWho to callowners, IT, Vercel andSupabase supportDeploymerge; what deploy.yml does;how to checkRoll back the codeVercel Instant Rollback, thenundo itFix a migrationforward, with a new migrationRestore a backupthe drill, its time, the RPOand RTOKnown problemssymptom, check, fixDrill logdate, who, minutes, whatchanged
The runbook this session writes. The amber sections are the ones drilled today; the drill log is what makes the rest believable.
Step 10

Write the runbook from the repository, then make it true

10 minutes

Why

When the platform misbehaves at 03:00 and you are on holiday, owner two follows a page, not your memory. The repository already knows most of that page: the workflows, the key names, the drills you just did. Claude Code drafts it from them in minutes; you fill in what only people know (who to call, the recovery numbers, the drill times), and owner two approves it only if they could follow it without you.

Do this

Paste into Claude Code
Read CLAUDE.md, docs/KEYS.md, .github/workflows/, supabase/migrations/ and the /status page.

On a new branch docs/runbook, write docs/runbook.md in plain English for the second owner, sam@acme.com, who must be able to follow it without me:
1. What it is: the live address https://acme-platform.vercel.app, the repository acme-ops/acme-platform, the Supabase projects acme-platform-prod (production) and acme-platform-dev (development), the Vercel project, and the owners.
2. Who to call: a table for me to fill in (role, name, phone, hours).
3. Deploy: merging to main is the only way. What deploy.yml does, step by step, and how to check it worked (the deploy run, Vercel, /status). Say plainly that nobody runs supabase db push for production, and nobody deploys from a computer.
4. Roll back the code: Vercel Instant Rollback, then Undo Rollback once fixed. What it does not undo.
5. Fix a migration: always forward, with a new migration; never edit an applied file.
6. Restore a backup: where backups are, the restore-drill workflow, why a drill never restores into production, the weekly offline copy, and our recovery point and recovery time objectives (leave them for me to fill in).
7. Keys: every secret and variable by NAME from docs/KEYS.md, where it is set, who holds it and how to replace it; never a value.
8. Daily: read the prod-freshness and backup results; a red one without an open issue is a defect.
9. Known problems: a table (symptom, check, fix) starting with: deploy failed in migrate-production; prod-freshness red; a canceled production deployment; a build out of memory; a red check on an old commit.
10. Drill log: a table (date, who, procedure, minutes, what changed) with today's rollback drill and restore drill; leave the minutes for me to fill in.
Every step names the exact page or command. Open a pull request titled "Runbook", and confirm that no key, password or token value appears anywhere in it.

Fill in Who to call, the two recovery numbers you agreed with the supervisors, and the drill minutes, in the pull request's Files changed tab (edit the file there) or by telling Claude Code. Owner two reads it as if you were away, and approves only if they could follow every step.

You will see recreated screen

claude — acme-platform
⏺ Read(.github/workflows/deploy.yml)
⎿ Read 74 lines
⏺ Read(docs/KEYS.md)
⎿ Read 31 lines
⏺ Write(docs/runbook.md)
+## 3. Deploy
+Merging a pull request to main is the only way anything reaches production.
+Nobody runs supabase db push for production; nobody deploys from a computer.
+1. deploy.yml checks its secrets, applies migrations to development, then production.
+2. Vercel makes the new build live only when deploy / migrate-production is green.
1
⏺ Write(docs/runbook.md)
+## 10. Drill log
+| Date | Who | Procedure | Minutes | What changed |
+| 2026-10-21 | pat@acme.com | Rollback drill | (fill in) | none |
+| 2026-10-21 | pat@acme.com | Restore drill | (fill in) | none |
2
⏺ Pull request #41 adds docs/runbook.md with ten sections. I checked every line: it names secrets and variables only, and contains no key, password or token value. You need to fill in Who to call, the recovery point and time objectives, and the two drill times.3
The draft, built from what is in the repository. The gaps it leaves are the ones only people can fill.
  1. The sentence that matters most after this session, in the runbook where owner two will read it.
  2. The drills you did today, ready for their times.
  3. It says what is missing. Those gaps are yours to fill, not Claude Code's to guess.

Check it worked

docs/runbook.md is on main with ten sections, Who to call and the recovery numbers filled in, both drills in the log with their times, no key value anywhere, and owner two's approval.

If it goes wrong

A key, password or token value appears in the draft

Stop. Do not merge. Say: Remove every value; name the key and where it is set instead. Then treat that key as exposed: replace it the same day (the runbook's Keys section says how) and note the date in docs/KEYS.md. A runbook is printed; a key on paper is a key on the notice board.

The runbook describes something nobody has done

Mark that section not yet drilled. Only what has been done and timed is proven; Session 23 adds the witnessed restore drill.

Owner two cannot follow a step

That is the review working. Fix the step in the same pull request until they can. A runbook only its author can follow is a diary.

Before you go on · Session 11 is done whenTick each one

Knowledge check

What does a Vercel Instant Rollback not undo?

Knowledge check

A migration already applied in production has a mistake. What do you do?

Knowledge check

Which backup counts as proven?

References

  1. Vercel Docs: Instant Rollback. https://vercel.com/docs/instant-rollback
  2. NIST SP 800-34 Rev. 1: Contingency Planning Guide for Federal Information Systems. https://csrc.nist.gov/pubs/sp/800/34/r1/upd1/final
  3. Supabase Docs: Database backups. https://supabase.com/docs/guides/platform/backups
  4. CISA: #StopRansomware Guide. https://www.cisa.gov/stopransomware/ransomware-guide
  5. PostgreSQL Documentation: pg_dump. https://www.postgresql.org/docs/current/app-pgdump.html
  6. Supabase Docs: Backup and restore using the CLI. https://supabase.com/docs/guides/platform/migrating-within-supabase/backup-restore
  7. GitHub Docs: Storing and sharing data from a workflow (artifacts). https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/storing-and-sharing-data-from-a-workflow

Chapter 4 · 12 questions · 80% passes

Final assessment

Twelve questions across the session. Score 80% (10 of 12) to pass. Your LMS records your score and each answer; you can review the chapters and try again.

15 min12 questions≈ 15 minutesRetake allowed

Choose one answer for each question, then submit. You will see the right answer and why for every question.

1. After Session 11, who applies a merged migration to the production database?
2. Why do previews use the development project?
3. A production deployment shows no commit and was made from the command line. What does it mean?
4. Where do the deploy's Supabase access token and database password live?
5. The deploy fails in migrate-production. What does the plant see?
6. What does Vercel's Instant Rollback not undo?
7. A migration already applied in production contains a mistake. What do you do?
8. Why does the daily freshness check exist?
9. A morning check has been red for days and nobody has been told. What does that mean?
10. A pull request is red for a reason unrelated to it, and the run is on an old commit. What do you do?
11. What makes a backup trustworthy?
12. Why does the restore drill refuse to start when its target contains the production project id?