Skip to content

rustybuns deploy: adopt existing Cloudflare resources by the names in the config #140

Closed

Description

@QuinnsCode

rustybuns plan/deploy doesn't pass the config's names to Alchemy. The Worker gets no name (the config's name), and D1 gets no databaseName, nor R2 a bucketName (packages/cli/src/gen/alchemy.ts). So Alchemy makes <app>-<id>-<stage>-<random> names, and a stack whose local state is gone plans to create everything again.

What happened: codesplitters is live as Worker codesplitters with D1 codesplitters-db, made with wrangler. rustybuns plan wanted to create a new Worker and a new, empty database beside them, so we deployed with wrangler deploy instead. The same thing already left four orphaned druids-curse-...-DB-live-ryanquinn-* databases (see the cleanup issue).

Fix:

  • Emit the explicit names: Worker name: cfg.name, D1 name: databaseName, R2 name: bucketName. Alchemy's D1 already adopts a database by name when creating it hits "already exists".
  • Pass --adopt when nothing's in state.
  • Careful with live Alchemy-managed apps (hippo, druids): a name change replaces resources there, so do it per app or behind a flag.
  • Alchemy keeps state in .alchemy/ inside the worktree (Alchemy.localState()), so state is lost when a worktree is deleted. Consider a state store that outlives the worktree.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions