feat: add production D1 database config and fix prod scripts#148
Merged
Conversation
Add environment-specific D1 database binding, durable objects, and migrations under [env.production] in wrangler.toml. Add --env production flag to db:migrate:prod and db:seed:prod scripts so they resolve the correct database ID.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Cloudflare Wrangler configuration and npm scripts to ensure production uses its own D1 database configuration and that production DB commands target the production environment.
Changes:
- Add
[env.production]D1 database + durable object + migrations configuration inwrangler.toml. - Update
db:migrate:prodanddb:seed:prodscripts to pass--env productionso Wrangler resolves the production D1 database ID.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| wrangler.toml | Adds production environment configuration for D1, durable objects, and migrations. |
| package.json | Updates production DB migration/seed scripts to use --env production. |
| NODE_ENV = "production" | ||
|
|
||
| [[env.production.d1_databases]] | ||
| binding = "mlack_db" |
There was a problem hiding this comment.
[[env.production.d1_databases]] uses binding = "mlack_db", but the runtime code/types consistently expect the D1 binding to be DB (e.g., c.env.DB). With the current config, production deployments will have c.env.DB undefined and DB access will fail. Use the same binding name (DB) in the production env (or update all code/types to use the new binding name).
Suggested change
| binding = "mlack_db" | |
| binding = "DB" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
[env.production]inwrangler.tomlso dev and production use separate D1 databases.--env productionflag todb:migrate:prodanddb:seed:prodnpm scripts so they resolve the production database ID instead of the top-level"local"placeholder.