Switch from PGlite (WebAssembly) to embedded-postgres for zero-config local development — provides a real PostgreSQL server with full compatibility. Add startup banner with config summary on server boot. Improve server bootstrap with auto port detection, database creation, and migration on startup. Update DATABASE.md, DEVELOPING.md, and SPEC-implementation.md to reflect the change. Update CLI database check and prompts. Simplify OnboardingWizard database options. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
18 lines
526 B
TypeScript
18 lines
526 B
TypeScript
import { migrate as migratePg } from "drizzle-orm/postgres-js/migrator";
|
|
import postgres from "postgres";
|
|
import { drizzle as drizzlePg } from "drizzle-orm/postgres-js";
|
|
|
|
const migrationsFolder = new URL("./migrations", import.meta.url).pathname;
|
|
const url = process.env.DATABASE_URL;
|
|
|
|
if (!url) {
|
|
throw new Error("DATABASE_URL is required for db:migrate");
|
|
}
|
|
|
|
const sql = postgres(url, { max: 1 });
|
|
const db = drizzlePg(sql);
|
|
await migratePg(db, { migrationsFolder });
|
|
await sql.end();
|
|
|
|
console.log("Migrations complete");
|