Skip to content

Commit d5c1b7b

Browse files
committed
fix: load dotenv before env validation in drizzle config
1 parent 0868d9c commit d5c1b7b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

apps/web/drizzle.config.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import type { Config } from "drizzle-kit";
22
import * as dotenv from "dotenv";
3-
import { webEnv } from "@/lib/env/web";
43

5-
if (webEnv.NODE_ENV === "production") {
4+
if (process.env.NODE_ENV === "production") {
65
dotenv.config({ path: ".env.production" });
76
} else {
87
dotenv.config({ path: ".env.local" });
98
}
109

10+
const databaseUrl = process.env.DATABASE_URL;
11+
if (!databaseUrl) {
12+
throw new Error("DATABASE_URL is not set");
13+
}
14+
1115
export default {
1216
schema: "./src/schema.ts",
1317
dialect: "postgresql",
1418
migrations: {
1519
table: "drizzle_migrations",
1620
},
1721
dbCredentials: {
18-
url: webEnv.DATABASE_URL,
22+
url: databaseUrl,
1923
},
2024
out: "./migrations",
21-
strict: webEnv.NODE_ENV === "production",
25+
strict: process.env.NODE_ENV === "production",
2226
} satisfies Config;

0 commit comments

Comments
 (0)