-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrizzle.config.ts
More file actions
35 lines (32 loc) · 849 Bytes
/
drizzle.config.ts
File metadata and controls
35 lines (32 loc) · 849 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
28
29
30
31
32
33
34
35
import { schemaPath } from "@listee/db";
import { loadEnvConfig } from "@next/env";
import { defineConfig } from "drizzle-kit";
import { ZodError } from "zod";
import { getEnv } from "./src/app/env";
loadEnvConfig(process.cwd());
const databaseUrl = (() => {
try {
return getEnv().POSTGRES_URL;
} catch (error) {
if (error instanceof ZodError) {
const issue = error.issues.find((entry) => {
return entry.path.join(".") === "POSTGRES_URL";
});
if (issue !== undefined) {
if (issue.code === "invalid_type") {
throw new Error("POSTGRES_URL is not set.");
}
throw new Error(issue.message);
}
}
throw error;
}
})();
export default defineConfig({
dialect: "postgresql",
schema: schemaPath,
out: "./drizzle",
dbCredentials: {
url: databaseUrl,
},
});