Skip to content

fix(template-generator): align d1 setup instructions - #1066

Merged
AmanVarshney01 merged 1 commit into
mainfrom
aman/fix-d1-readme-instructions
Jun 3, 2026
Merged

AmanVarshney01 merged 1 commit into
mainfrom
aman/fix-d1-readme-instructions

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Jun 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • omit db:push from generated D1 + Cloudflare projects so local SQLite push is not presented as D1 setup
  • update generated README output to label Cloudflare D1, clarify the DB binding vs local DATABASE_URL, and list D1 migration commands
  • refresh Cloudflare Alchemy docs for D1 migration directories and D1 troubleshooting

Fixes #1035

Verification

  • bun run check
  • bun run build:cli
  • Scaffolded the Cloudflare D1 Setup Not Working #1035 command locally and verified generated root/db scripts omit db:push, while README points to db:generate/db:migrate and the D1 DB binding

Summary by CodeRabbit

Release Notes

  • Documentation

    • Updated Cloudflare+Alchemy guide with clarified migration commands and binding configuration
    • Expanded project structure notes to document database script behavior with D1+Cloudflare
  • Improvements

    • Enhanced template generation to properly handle database scripts for D1+Alchemy configurations, conditionally including db:push based on database backend

@vercel

vercel Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
create-better-t-stack-web Ready Ready Preview, Comment Jun 3, 2026 5:30pm

Request Review

@AmanVarshney01
AmanVarshney01 marked this pull request as ready for review June 3, 2026 17:41
@AmanVarshney01
AmanVarshney01 merged commit 3d3b9e4 into main Jun 3, 2026
3 checks passed
@AmanVarshney01
AmanVarshney01 deleted the aman/fix-d1-readme-instructions branch June 3, 2026 17:41
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed36ff56-3a55-490a-a099-fd3420265186

📥 Commits

Reviewing files that changed from the base of the PR and between 615ffae and 5e62df2.

📒 Files selected for processing (5)
  • apps/web/content/docs/guides/cloudflare-alchemy.mdx
  • apps/web/content/docs/project-structure.mdx
  • packages/template-generator/src/post-process/package-configs.ts
  • packages/template-generator/src/processors/readme-generator.ts
  • packages/template-generator/src/utils/db-scripts.ts

Walkthrough

This PR conditions database script generation and README documentation on D1+Alchemy mode. When dbSetup is "d1", the configuration gates db:push and db:studio scripts and generates D1-specific setup instructions. Non-D1 setups continue to include all scripts as before.

Changes

D1+Alchemy Conditional Script and Setup Handling

Layer / File(s) Summary
D1 script capability detection
packages/template-generator/src/utils/db-scripts.ts
getDbScriptSupport derives hasDbPush and hasDbStudio from !isD1Alchemy and exports the isD1Alchemy flag to signal D1 mode downstream.
Package config script generation with gates
packages/template-generator/src/post-process/package-configs.ts
updateRootPackageJson and updateDbPackageJson compute dbSupport once and guard db:push assignment with the hasDbPush flag for both Prisma and Drizzle.
README generation with dbSetup and script gates
packages/template-generator/src/processors/readme-generator.ts
generateReadmeContent passes dbSetup to downstream helpers. generateFeaturesList labels SQLite as "Cloudflare D1" or "SQLite/Turso" based on dbSetup. generateDatabaseSetup detects isD1Alchemy and emits D1-specific setup text with optional db:generate and db:migrate steps. generateScriptsList gates db:push on hasDbPush.
D1+Alchemy guide and structure documentation
apps/web/content/docs/guides/cloudflare-alchemy.mdx, apps/web/content/docs/project-structure.mdx
Migration directory guidance, binding examples, and troubleshooting steps in the Cloudflare+Alchemy guide are updated to reflect D1+Alchemy workflows. Project structure docs note that db:push is omitted under D1+Cloudflare.

Possibly related PRs


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 and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e62df2462

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +600 to +603
steps.push(`${steps.length + 1}. Create and apply Prisma migrations locally:
\`\`\`bash
${packageManagerRunCmd} db:migrate
\`\`\``);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add the missing Prisma D1 migration DATABASE_URL

For Prisma + Cloudflare D1 projects, this new README step tells users to run db:migrate, but the generated env files do not define DATABASE_URL for D1 (processors/env-vars.ts only emits it when dbSetup === "none"), while the Prisma SQLite config still reads env("DATABASE_URL") from templates/db/prisma/sqlite/prisma.config.ts.hbs. A fresh D1 project following these instructions will fail the migration command before creating migrations unless the user guesses and adds a local SQLite URL; please either document that prerequisite here or avoid instructing users to run the command without it.

Useful? React with 👍 / 👎.

This branch was successfully deployed

1 active deployment
Preview — 5e62df24 Deployed Jun 3, 2026 by vercel[bot]
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.

Cloudflare D1 Setup Not Working

1 participant