From 973cc688328e3ff28780f7c692d684d32e7b94be Mon Sep 17 00:00:00 2001 From: jknapp Date: Fri, 15 May 2026 08:06:06 -0700 Subject: [PATCH] fix(migrate): resolve migrations dir alongside or above the script When esbuild bundles migrate.ts to apps/web/migrate.mjs (one directory higher than the source location), the relative `..` path in the previous implementation pointed at apps/, not apps/web/. Try both layouts and allow an explicit MIGRATIONS_DIR override. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/web/scripts/migrate.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/web/scripts/migrate.ts b/apps/web/scripts/migrate.ts index 71eb8c3..1d49823 100644 --- a/apps/web/scripts/migrate.ts +++ b/apps/web/scripts/migrate.ts @@ -5,13 +5,31 @@ * features we need (pgvector, generated columns), so we manage migration * state ourselves in `_migrations` and apply files as plain SQL. */ +import { existsSync } from "node:fs"; import { readFile, readdir } from "node:fs/promises"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; import postgres from "postgres"; const __dirname = dirname(fileURLToPath(import.meta.url)); -const MIGRATIONS_DIR = join(__dirname, "..", "drizzle"); + +// Resolve the migrations directory. Try, in order: +// 1. $MIGRATIONS_DIR env override (explicit deploy-time control) +// 2. `