From 21bd0f6227ba662587bbf72508048ed6c3bc73c6 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Sat, 20 Jun 2026 18:32:44 +0200 Subject: [PATCH] fix(db): point db:migrate at the live appliance DB by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `db:migrate` (and drizzle-kit's config default) resolved DATABASE_URL to `./parking.sqlite` relative to packages/db — a stray, half-empty leftover DB, not the real store at apps/server/parking.sqlite. Running `pnpm --filter @parking/db db:migrate` with no env therefore migrated the wrong file and failed on its broken state, while the real DB went untouched. Default DATABASE_URL to ../../apps/server/parking.sqlite in both the db:migrate script and drizzle.config.ts (an explicit DATABASE_URL still overrides). The stray packages/db/parking.sqlite was untracked + already gitignored (*.sqlite); deleted it from disk. Now `pnpm --filter @parking/db db:migrate` targets the appliance DB out of the box. Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V --- packages/db/drizzle.config.ts | 5 ++++- packages/db/package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/db/drizzle.config.ts b/packages/db/drizzle.config.ts index 65ea990..41c1b6b 100644 --- a/packages/db/drizzle.config.ts +++ b/packages/db/drizzle.config.ts @@ -8,6 +8,9 @@ export default defineConfig({ schema: "./src/schema.ts", out: "./drizzle", dbCredentials: { - url: process.env.DATABASE_URL ?? "./parking.sqlite", + // Default to the live appliance DB (apps/server), NOT a stray ./parking.sqlite in + // this package. The `db:migrate` script also sets DATABASE_URL to this. Override with + // DATABASE_URL to target another DB. + url: process.env.DATABASE_URL ?? "../../apps/server/parking.sqlite", }, }); diff --git a/packages/db/package.json b/packages/db/package.json index 125a2fd..13903fc 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -21,7 +21,7 @@ "typecheck": "tsc --noEmit", "lint": "tsc --noEmit", "db:generate": "drizzle-kit generate", - "db:migrate": "drizzle-kit migrate" + "db:migrate": "DATABASE_URL=\"${DATABASE_URL:-../../apps/server/parking.sqlite}\" drizzle-kit migrate" }, "dependencies": { "@parking/shared": "workspace:*",