19 lines
482 B
TypeScript
19 lines
482 B
TypeScript
// CLI migration runner (local / CI). Run via `bun run migrate`.
|
|
// Production migrations run automatically via server/plugins/migrate.ts on startup.
|
|
import postgres from "postgres";
|
|
import { INIT_SQL } from "../utils/schema";
|
|
|
|
const url = process.env.DATABASE_URL;
|
|
if (!url) {
|
|
console.error("DATABASE_URL not set");
|
|
process.exit(1);
|
|
}
|
|
|
|
const sql = postgres(url, { max: 1 });
|
|
try {
|
|
await sql.unsafe(INIT_SQL);
|
|
console.log("schema applied");
|
|
} finally {
|
|
await sql.end();
|
|
}
|