Files
famdone/frontend/src/lib/server/migrate-boot.ts
T
2026-08-17 07:41:26 +01:00

16 lines
520 B
TypeScript

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<void> | null = null;
export function migrateOnBoot(): Promise<void> {
if (!done) {
done = migrate().catch((e) => {
console.error('[migrate] failed:', e);
});
}
return done;
}