-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdrizzle.config.ts
More file actions
44 lines (39 loc) · 1.08 KB
/
drizzle.config.ts
File metadata and controls
44 lines (39 loc) · 1.08 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
43
44
import { defineConfig } from "drizzle-kit";
// Get driver type from environment
// Default to PostgreSQL since all schemas use pgTable
const driver = process.env.DATABASE_DRIVER || "postgres";
const url =
process.env.DATABASE_URL ||
"postgresql://opencodehub:opencodehub@localhost:5432/opencodehub";
// Map driver to Drizzle dialect
const dialectMap: Record<string, "sqlite" | "postgresql" | "mysql" | "turso"> =
{
sqlite: "sqlite",
postgres: "postgresql",
mysql: "mysql",
libsql: "turso",
turso: "turso",
};
const dialect = dialectMap[driver] || "postgresql";
// Build credentials based on driver
function getCredentials() {
switch (driver) {
case "postgres":
case "mysql":
return { url, ssl: { rejectUnauthorized: false } };
case "libsql":
case "turso":
return { url, authToken: process.env.DATABASE_AUTH_TOKEN };
case "sqlite":
default:
return { url };
}
}
export default defineConfig({
schema: "./src/db/schema/index.ts",
out: "./drizzle",
dialect,
dbCredentials: getCredentials(),
verbose: true,
strict: true,
});