Skip to content

First deploy with D1 migrations: upload, wake, migrate, then live - #43

Merged
ryuzdev merged 2 commits into
mainfrom
first-deploy-migrate
Oct 24, 2026
Merged

ryuzdev merged 2 commits into
mainfrom
first-deploy-migrate

Conversation

@ryuzdev

@ryuzdev ryuzdev commented Oct 24, 2026

Copy link
Copy Markdown
Member

Found live while pinning template 60edb35 (its db/migrations/0001_item.sql starter): every new app's first deploy failed.

  1. Order. migrate() woke the fleet before applying (celld d1 reaches the database through a running node), but a first deploy has nothing uploaded yet, so the wake timed out (fleet tpl-first never became healthy). First deploy (last_deploy_sha IS NULL, read fresh from the row) now runs upload → wake → migrate → live. Apps with a live version keep migrate → upload. A failed first deploy stays not-live and retries on the same path; celld skips applied files.
  2. Proxy gate. The proxy forwarded as soon as a fleet was up; an app with no successful deploy now gets 503 retry-after: 2 ("being built"), so nobody is served code before its migrations finish.
  3. Permissions. Outer stages migration files as root under the sandbox's 077 umask, but celld d1 migrations apply runs as the app uid, so celld saw "no migrations directory". Staged dirs Outer owns become 0755 and files 0644 via fchmod on O_NOFOLLOW fds (readable, not writable, by the app).
  4. Operator CLI (no fleet manager): the lease error becomes "first deploy with D1 migrations needs the server; deploy through MCP". d1.md, module docs and comments agree with the code.

Tests: upload/wake/migrate order on first deploy, first-deploy migrate failure → failed + not live, retry stays on the first-deploy path, proxy refuses before first success, staged files readable under a 077 umask. 446 pass.

Live: released outer:ed9fd09; create_app tpl-first3 through MCP on template 60edb35 → success in 33 s (steps worktree, install, build, gate, deploy-root, deploy, migrate), page renders at 390 px with no console errors. Test app and key deleted.

CodeRabbit is out of free reviews; merging on green CI plus the live check above.

First deploys have nothing published yet, so no fleet can start and the
pre-migrate wake times out. Reverse steps 6-7 for apps with no successful
deploy (last_deploy_sha NULL, read fresh from the row): upload first, wake,
then migrate; only a migrate success marks the app live. Existing apps keep
migrate-before-upload.

The proxy never forwards for an app with no successful deploy (503 building
page), so uploaded-but-unmigrated code is never served. First-deploy
migrate failures say 'Your app isn't live yet'; the operator CLI
(wake: None) translates the celld lease error into a deploy-through-MCP
hint.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d575c2a5-4b0f-4c0a-90a8-0a967e1afd50
Commits

Reviewing files that changed from the base of the PR and between 86f14dd and ed9fd09.

Files selected for processing: 4
  • crates/outer/src/deploy/migrate.rs
  • crates/outer/src/deploy/pipeline.rs
  • crates/outer/src/http/proxy.rs
  • web/docs/guides/d1.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ryuzdev
ryuzdev merged commit 250d429 into main Oct 24, 2026
4 checks passed
@ryuzdev
ryuzdev deleted the first-deploy-migrate branch October 24, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant