Avoid db:local script for D1 database (#362)

Co-authored-by: Aman Varshney <amanvarshney.work@gmail.com>
This commit is contained in:
Martin Høst Normark
2025-06-30 15:56:49 +02:00
committed by GitHub
parent b64f3e1d5d
commit 8dc521c92a
3 changed files with 25 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"create-better-t-stack": patch
---
Avoid db:local script for D1 database

View File

@@ -5,6 +5,7 @@ import type {
Addons, Addons,
API, API,
Database, Database,
DatabaseSetup,
Frontend, Frontend,
ORM, ORM,
ProjectConfig, ProjectConfig,
@@ -96,7 +97,13 @@ ${packageManagerRunCmd} dev:setup
\`\`\` \`\`\`
Follow the prompts to create a new Convex project and connect it to your application.` Follow the prompts to create a new Convex project and connect it to your application.`
: generateDatabaseSetup(database, auth, packageManagerRunCmd, orm) : generateDatabaseSetup(
database,
auth,
packageManagerRunCmd,
orm,
options.dbSetup,
)
} }
Then, run the development server: Then, run the development server:
@@ -467,6 +474,7 @@ function generateDatabaseSetup(
_auth: boolean, _auth: boolean,
packageManagerRunCmd: string, packageManagerRunCmd: string,
orm: ORM, orm: ORM,
dbSetup: DatabaseSetup,
): string { ): string {
if (database === "none") { if (database === "none") {
return ""; return "";
@@ -484,9 +492,14 @@ function generateDatabaseSetup(
}. }.
1. Start the local SQLite database: 1. Start the local SQLite database:
\`\`\`bash ${
dbSetup === "d1"
? "Local development for a Cloudflare D1 database will already be running as part of the `wrangler dev` command."
: `\`\`\`bash
cd apps/server && ${packageManagerRunCmd} db:local cd apps/server && ${packageManagerRunCmd} db:local
\`\`\` \`\`\`
`
}
2. Update your \`.env\` file in the \`apps/server\` directory with the appropriate connection details if needed. 2. Update your \`.env\` file in the \`apps/server\` directory with the appropriate connection details if needed.
`; `;

View File

@@ -225,7 +225,11 @@ async function updateServerPackageJson(
const scripts = serverPackageJson.scripts; const scripts = serverPackageJson.scripts;
if (options.database !== "none") { if (options.database !== "none") {
if (options.database === "sqlite" && options.orm === "drizzle") { if (
options.database === "sqlite" &&
options.orm === "drizzle" &&
options.dbSetup !== "d1"
) {
scripts["db:local"] = "turso dev --db-file local.db"; scripts["db:local"] = "turso dev --db-file local.db";
} }