feat: dockerfile (node runtime), startup migration, README, runtime env config

This commit is contained in:
2026-06-10 08:16:45 +00:00
parent 56186a1fea
commit 7331fe75e8
12 changed files with 286 additions and 31 deletions

View File

@@ -1,8 +1,7 @@
// Idempotent migration runner. Run via `bun run migrate` / on container start.
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
// 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) {
@@ -10,14 +9,10 @@ if (!url) {
process.exit(1);
}
const here = dirname(fileURLToPath(import.meta.url));
const sql = postgres(url, { max: 1 });
try {
const ddl = readFileSync(join(here, "migrations", "0001_init.sql"), "utf8");
// Trusted local DDL file, not user input.
await sql.unsafe(ddl);
console.log("migration 0001_init applied");
await sql.unsafe(INIT_SQL);
console.log("schema applied");
} finally {
await sql.end();
}