-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrizzle.config.ts
More file actions
24 lines (22 loc) · 814 Bytes
/
drizzle.config.ts
File metadata and controls
24 lines (22 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import fs from "node:fs";
import path from "node:path";
import { defineConfig } from "drizzle-kit";
function findLocalD1Database(): string {
const d1Dir = path.join(".wrangler", "state", "v3", "d1", "miniflare-D1DatabaseObject");
if (!fs.existsSync(d1Dir)) {
throw new Error(`D1 directory not found: ${d1Dir}\nRun "pnpm dev" once to initialize the local database.`);
}
const sqliteFile = fs.readdirSync(d1Dir).find((f) => f.endsWith(".sqlite"));
if (!sqliteFile) {
throw new Error(`No .sqlite file found in ${d1Dir}\nRun "pnpm dev" once to initialize the local database.`);
}
return path.join(d1Dir, sqliteFile);
}
export default defineConfig({
schema: "./hono/db/schema.ts",
out: "./hono/db/migrations",
dialect: "sqlite",
dbCredentials: {
url: findLocalD1Database(),
},
});