/** * Run pending SQL migrations from ./drizzle in lexical filename order. * * Lightweight runner — drizzle-kit's TS migrator doesn't handle the raw SQL * 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)); // Resolve the migrations directory. Try, in order: // 1. $MIGRATIONS_DIR env override (explicit deploy-time control) // 2. `