Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"lint": "biome lint",
"check": "biome check",
"check-types": "tsc --noEmit",
"migrate": "node ../../scripts/run-d1-migrations.mjs quickhub-db",
"migrate": "pnpm run migrate:local",
"migrate:local": "node ../../scripts/run-d1-migrations.mjs quickhub-db --local",
"migrate:remote": "node ../../scripts/run-d1-migrations.mjs quickhub-db --remote",
"deploy": "pnpm run build && wrangler deploy"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "quickhub-dashboard",
"name": "quickhub",
"compatibility_date": "2025-09-02",
"compatibility_flags": ["nodejs_compat"],
"main": "@tanstack/react-start/server-entry",
"d1_databases": [
{
"binding": "DB",
"database_name": "quickhub-db",
"database_id": "placeholder-create-with-wrangler-d1-create",
"database_id": "7a94a843-0906-416c-9908-4c9fe5339db7",
"migrations_dir": "drizzle"
}
]
Expand Down
14 changes: 11 additions & 3 deletions scripts/run-d1-migrations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ import { spawnSync } from "node:child_process";
import { getSharedWranglerStatePath, isWorktreeCheckout } from "./shared-worktree-paths.mjs";

const databaseName = process.argv[2];
const mode = process.argv[3] ?? "--local";

if (!databaseName) {
console.error("Usage: node scripts/run-d1-migrations.mjs <database-name>");
console.error(
"Usage: node scripts/run-d1-migrations.mjs <database-name> [--local|--remote]",
);
process.exit(1);
}

const args = ["exec", "wrangler", "d1", "migrations", "apply", databaseName, "--local"];
if (mode !== "--local" && mode !== "--remote") {
console.error(`Unsupported mode "${mode}". Use --local or --remote.`);
process.exit(1);
}

const args = ["exec", "wrangler", "d1", "migrations", "apply", databaseName, mode];

if (isWorktreeCheckout()) {
if (mode === "--local" && isWorktreeCheckout()) {
args.push("--persist-to", getSharedWranglerStatePath());
}

Expand Down