migrate from hono
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user