Skip to content

Commit 8dc521c

Browse files
Avoid db:local script for D1 database (#362)
Co-authored-by: Aman Varshney <[email protected]>
1 parent b64f3e1 commit 8dc521c

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

.changeset/itchy-bikes-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-better-t-stack": patch
3+
---
4+
5+
Avoid db:local script for D1 database

apps/cli/src/helpers/project-generation/create-readme.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
Addons,
66
API,
77
Database,
8+
DatabaseSetup,
89
Frontend,
910
ORM,
1011
ProjectConfig,
@@ -96,7 +97,13 @@ ${packageManagerRunCmd} dev:setup
9697
\`\`\`
9798
9899
Follow the prompts to create a new Convex project and connect it to your application.`
99-
: generateDatabaseSetup(database, auth, packageManagerRunCmd, orm)
100+
: generateDatabaseSetup(
101+
database,
102+
auth,
103+
packageManagerRunCmd,
104+
orm,
105+
options.dbSetup,
106+
)
100107
}
101108
102109
Then, run the development server:
@@ -467,6 +474,7 @@ function generateDatabaseSetup(
467474
_auth: boolean,
468475
packageManagerRunCmd: string,
469476
orm: ORM,
477+
dbSetup: DatabaseSetup,
470478
): string {
471479
if (database === "none") {
472480
return "";
@@ -484,9 +492,14 @@ function generateDatabaseSetup(
484492
}.
485493
486494
1. Start the local SQLite database:
487-
\`\`\`bash
495+
${
496+
dbSetup === "d1"
497+
? "Local development for a Cloudflare D1 database will already be running as part of the `wrangler dev` command."
498+
: `\`\`\`bash
488499
cd apps/server && ${packageManagerRunCmd} db:local
489500
\`\`\`
501+
`
502+
}
490503
491504
2. Update your \`.env\` file in the \`apps/server\` directory with the appropriate connection details if needed.
492505
`;

apps/cli/src/helpers/project-generation/project-config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ async function updateServerPackageJson(
225225
const scripts = serverPackageJson.scripts;
226226

227227
if (options.database !== "none") {
228-
if (options.database === "sqlite" && options.orm === "drizzle") {
228+
if (
229+
options.database === "sqlite" &&
230+
options.orm === "drizzle" &&
231+
options.dbSetup !== "d1"
232+
) {
229233
scripts["db:local"] = "turso dev --db-file local.db";
230234
}
231235

0 commit comments

Comments
 (0)