Skip to content

Clarify how to bind different D1 databases on preview URLs after migrating from Pages → Workers #23377

@magbicaleman

Description

@magbicaleman

Proposed changes

Please add a short section to the Previews docs that answers:

  • Can a Worker that was migrated from Pages point at a different D1 database for its *.workers.dev preview URL?
    • If yes, document the two recommended approaches (e.g. preview_database_id vs. an explicit [env.preview] block).
    • Show a minimal wrangler.toml / wrangler.jsonc snippet for each.
  • Explain how this differs from the behaviour Pages had with preview deployments.
  • Mention any “gotchas” (for example: wrangler dev --remote uses preview_database_id; wrangler deploy always uses the section you deploy).

This would save users from hunting through Discord / blog posts when they are simply trying to keep production and preview data separate.

Subject Matter

D1 + Workers configuration – preview-time database binding

Content Location

Primary:
https://developers.cloudflare.com/workers/configuration/previews/

Also reference:
https://developers.cloudflare.com/workers/static-assets/migration-guides/migrate-from-pages/
(in the D1 section of the migration guide)

Additional information

No response

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions