Skip to content

How to Upgrade

Rahil Pirani edited this page Jul 22, 2026 · 5 revisions

How to Upgrade

Upgrading Second Brain is simple: get the latest Worker deployed. You do not need to run any database migrations by hand — the Worker migrates its own schema automatically on the first request after each deploy.

No new environment variables are needed unless a release note says otherwise.

Whichever way you upgrade, your memories, password, and connected tools are preserved — an upgrade only replaces the Worker code.


Desktop app (easiest — works however you originally deployed)

The desktop app can upgrade any Second Brain on a .workers.dev address, including ones set up with the one-click button or manually.

If you already use the app: it checks your deployed version on launch and offers the upgrade automatically — accept the prompt, sign in to Cloudflare when asked, done.

If you don't have the app yet:

  1. Download it and open it.
  2. Choose "Already have a Second Brain?" and enter your brain's address and password. This doesn't touch your Cloudflare account — it just connects the app.
  3. The app notices your deployed Worker is behind the version it ships with and offers to update it. Accept, sign in to Cloudflare once in the browser window that opens, and the app redeploys the Worker in place.

If your brain is behind a custom domain (not .workers.dev), the app can't auto-locate the account — use one of the git methods below instead.

Note for one-click deployers: the app updates the Worker directly, so the copy of the repo in your GitHub account stays on the old version. That's harmless — but if you later push a change to that repo, Cloudflare will rebuild from it and roll the Worker back. If you actively use your repo, keep it synced too (next section).


One-Click Deploy

The "Deploy to Cloudflare" button creates a standalone copy of this repo in your GitHub account — not a fork — so GitHub's "Sync fork" button won't appear. To pull in the latest release, add this repo as a remote and merge:

# Clone the repo the deploy button created in your account
git clone https://github.com/YOUR-USERNAME/second-brain.git
cd second-brain

# One-time: add this repo as the upstream remote
git remote add upstream https://github.com/rahilp/second-brain-cloudflare.git

git fetch upstream
git merge upstream/main
git push

The push triggers Cloudflare's connected build, which redeploys the Worker automatically. To confirm: Workers & Pages → your Worker → Deployments should show a recent timestamp.

(No terminal handy? The desktop app above upgrades the deployed Worker without touching git.)


Manual Deploy (fork + terminal)

If you deploy from your machine:

# One-time: add the upstream remote if you haven't already
git remote add upstream https://github.com/rahilp/second-brain-cloudflare.git

git pull upstream main
npm install
npm run deploy

That's it. Send a test recall or open your web UI to confirm everything works.


What about database migrations?

You don't need to run them manually. The Worker calls initializeDatabase() on the first request after every deploy. It creates the table if it's missing and adds any new columns idempotently — already-present columns are skipped safely. So an upgrade just needs a redeploy; the schema catches up on its own.

(If you're setting up a brand-new database from the terminal, npm run db:migrate:remote still initializes it — but that's for first-time setup, not upgrades.)


Troubleshooting

If something looks off after an upgrade:

  • Give it one request — the schema migration runs on the first request after deploy.
  • Confirm the deploy actually landed (Deployments tab shows a recent timestamp).
  • Check the release notes for the version you're moving to in case it calls out anything special.

Still stuck? Open an issue with your upgrade method, the error message, and which version you upgraded from and to.

Clone this wiki locally