forked from codechefPesuecc/CodeChef-PESUECC-Chapter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
20 lines (20 loc) · 839 Bytes
/
Copy pathinstrumentation.ts
File metadata and controls
20 lines (20 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
* Next.js runs `register()` once when a server instance starts. We use it to
* apply DB migrations automatically (dev and in the Docker image), so the SQLite
* file is always schema-current without a manual step. Node runtime only —
* guarded so it never runs in the Edge runtime or during static prerender.
*/
export async function register() {
if (process.env.NEXT_RUNTIME !== "nodejs") return;
// On Cloudflare Workers the database is D1, migrated out-of-band via
// `wrangler d1 migrations apply`. Skip the local libSQL migrator there — it
// would try to touch the filesystem, which Workers don't have.
if (
typeof navigator !== "undefined" &&
navigator.userAgent === "Cloudflare-Workers"
) {
return;
}
const { runMigrations } = await import("./server/db/migrate");
await runMigrations();
}