import { migrate } from './migrate'; // Runs the PocketBase schema migration once per server process, at boot. // Idempotent (migrate() diffs against existing collections), so re-running on // dev HMR or restarts is a cheap no-op. Errors are logged, not thrown, so a // migration hiccup never takes the server down. let done: Promise | null = null; export function migrateOnBoot(): Promise { if (!done) { done = migrate().catch((e) => { console.error('[migrate] failed:', e); }); } return done; }