-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprisma.config.ts
More file actions
42 lines (39 loc) · 1.13 KB
/
prisma.config.ts
File metadata and controls
42 lines (39 loc) · 1.13 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import path from "node:path";
import fs from "node:fs";
import { defineConfig } from "prisma/config";
// Load .env manually since Prisma CLI doesn't auto-load it
function loadEnv() {
if (process.env.DATABASE_URL) return;
const envPath = path.resolve(process.cwd(), ".env");
if (!fs.existsSync(envPath)) return;
const content = fs.readFileSync(envPath, "utf-8");
for (const line of content.split("\n")) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith("#")) continue;
const eqIdx = trimmed.indexOf("=");
if (eqIdx === -1) continue;
const key = trimmed.slice(0, eqIdx).trim();
let val = trimmed.slice(eqIdx + 1).trim();
// Strip surrounding quotes
if (
(val.startsWith('"') && val.endsWith('"')) ||
(val.startsWith("'") && val.endsWith("'"))
) {
val = val.slice(1, -1);
}
if (!process.env[key]) {
process.env[key] = val;
}
}
}
loadEnv();
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
seed: "node prisma/seed.js",
},
datasource: {
url: process.env.DATABASE_URL ?? "",
},
});