Skip to content

10. Deploying updates

Once everything is set up, day-to-day changes are simple. This page covers shipping code changes, the local development loop, and applying new database migrations.

Shipping a code change

Because Cloudflare Pages watches GitHub, deploying is just pushing to GitHub:

git add .
git commit -m "Describe what you changed"
git push

Cloudflare detects the push, runs npm run build, and publishes automatically within a few minutes. Watch progress in your Pages project → Deployments.

Roll back instantly

If a deploy misbehaves, open Deployments, find the previous good one, and click ⋯ → Rollback. No code changes needed.

If your change includes a database migration

If the change added a new file under migrations/ (e.g. 0011_*.sql), the live database needs it too. After the deploy, run:

npm run db:migrate:remote

(See Run database migrations.) Code that expects a new column will error until the matching migration is applied to the remote database, so do this promptly after pushing such a change.

Running the app locally

To develop or test on your own machine before pushing.

One-time per machine:

cd "C:\LocalDev\On Call Scheduling\oncall-scheduler"
npm install
npm run db:migrate:local   # builds the local database
npm run build              # so the API server has something to serve

Then, the recommended dev loop — one command that starts both the API and the live-reloading web app:

npm run dev:all

This runs the API (Cloudflare functions + local D1) and the React app together. Open http://localhost:5173. Edits to the app reload instantly.

Prefer two terminals? That works too

npm run dev:all is just a convenience wrapper. The equivalent is two terminals:

npm run dev:api   # Terminal 1 — API + local D1 on :8788
npm run dev       # Terminal 2 — React app on :5173

Don't develop against npm run pages:dev

pages:dev serves the pre-built bundle with no hot reload — your edits won't show until you re-run npm run build. Use it only for a production-like smoke test: npm run build && npm run pages:dev.

In local dev there's no Cloudflare Access in front, so the dev:api / pages:dev scripts set DEV_ADMIN=1 (via .dev.vars) to treat you as an admin. Production never sets this — see the security note.

Quick checks before pushing

npm test          # unit tests
npm run lint      # code style
npm run typecheck # TypeScript checks
npm run test:e2e  # end-to-end tests (run npx playwright install once first)

Handy diagnostics on the live site

  • https://oncall.totlcom.com/api/v1/health — confirms the API is up.
  • https://oncall.totlcom.com/api/v1/me — shows your signed-in email and role.

Deploy this docs site