Skip to content

fix(dev): Start compose services and apply migrations when pnpm dev starts - #2421

Merged
thomasjiangcy merged 4 commits into
mainfrom
fix/dev-run-migrations
Oct 30, 2026
Merged

thomasjiangcy merged 4 commits into
mainfrom
fix/dev-run-migrations

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

pnpm dev did not start the local services or run migrations. Against a fresh database, the first conversation request failed with a 500: relation "junior_users" does not exist. Contributors had to know to run docker compose up -d and pnpm cli -- upgrade first.

scripts/dev-server.mjs now does both before the app starts:

  1. docker compose up -d --wait starts Postgres, Redis and S3 from compose.yaml and waits for their health checks. Services that already run are left as they are.
  2. After the package builds, junior upgrade (the example app's installed bin, on the fresh build) applies missing core and plugin migrations. Migrations that already ran are skipped.

If either step fails, pnpm dev stops with that command's error instead of serving a broken app. runRequiredChild now also stops with a clear message when a command cannot run at all, for example when docker is not installed. Before, a missing command was ignored. The contributor docs (contribute/development.md) describe this.

Verified locally (no .env.local):

  • Compose services stopped: pnpm dev started all three, waited until they were Healthy, reported Database is up to date (88 migrations)., then started Nitro. POST /api/conversations returned 200 accepted, and the worker logged conversation.work.lease.acquired.
  • Fresh empty database (first commit): Applied 88 migrations (88 total)., then the same request and lease. The turn stopped at model auth, which is expected with no gateway key.
  • Already-migrated database: a no-op upgrade adds about 3s to startup.
  • Unreachable DATABASE_URL: junior command failed: connect ECONNREFUSED ..., exit code 1.
  • No docker on PATH: Failed to run docker: spawnSync docker ENOENT, exit code 1.
  • Prettier and node --check pass on the changed files.

Open question: Docker is now required for pnpm dev. Someone who points DATABASE_URL and Redis at their own services still needs Docker running. Add an opt-out only if someone needs it.

No automated test added: this is dev-script wiring.

--

View Session [Sentry]

pnpm dev did not run migrations, so the first request against a fresh
database failed with `relation "junior_users" does not exist`. Run
`junior upgrade` after the package builds and before Nitro and the queue
worker start. It skips migrations that already ran, so it is safe on
every start.

Co-Authored-By: Thomas Jiang <20501235+thomasjiangcy@users.noreply.github.com>
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Oct 30, 2026 5:06am UTC

Request Review

Comment thread packages/docs/src/content/docs/contribute/development.md Outdated
Run `docker compose up -d --wait` first, so `junior upgrade` finds a
healthy Postgres without a manual step. Fail with a clear message when a
required command such as `docker` cannot run.
@sentry-junior sentry-junior Bot changed the title fix(dev): Apply database migrations when pnpm dev starts fix(dev): Start compose services and apply migrations when pnpm dev starts Oct 30, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a7c04b4. Configure here.

Comment thread scripts/dev-server.mjs
Without a fixed project name, Compose names the project after the checkout
folder. A worktree then starts a second project on the same host ports and
pnpm dev fails with a bind error. Name the project junior so every checkout
reuses the same services.
This reverts commit 362db17.

Co-Authored-By: Thomas Jiang <20501235+thomasjiangcy@users.noreply.github.com>
@thomasjiangcy
thomasjiangcy enabled auto-merge (squash) October 30, 2026 05:06
@thomasjiangcy
thomasjiangcy merged commit 508741b into main Oct 30, 2026
41 checks passed
@thomasjiangcy
thomasjiangcy deleted the fix/dev-run-migrations branch October 30, 2026 05:07

This branch was successfully deployed

1 active deployment
Preview – junior-docs — c1120416 Deployed Oct 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant