-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathdrizzle.config.ts
More file actions
27 lines (25 loc) · 885 Bytes
/
drizzle.config.ts
File metadata and controls
27 lines (25 loc) · 885 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
25
26
27
import fs from "fs";
// Load .env.local so DATABASE_URL is available when running `npx drizzle-kit migrate`.
// Inline loader avoids adding a `dotenv` dependency.
try {
const envLocal = fs.readFileSync(".env.local", "utf-8");
for (const line of envLocal.split("\n")) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith("#")) continue;
const idx = trimmed.indexOf("=");
if (idx === -1) continue;
const key = trimmed.slice(0, idx).trim();
const value = trimmed.slice(idx + 1).trim().replace(/^["']|["']$/g, "");
if (!process.env[key]) process.env[key] = value;
}
} catch {
// .env.local may not exist; that's fine – DATABASE_URL will use the default.
}
export default {
schema: "./src/lib/db/schema.ts",
out: "./drizzle",
dialect: "sqlite",
dbCredentials: {
url: process.env.DATABASE_URL || "./data/innoclaw.db",
},
};