-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrizzle.config.ts
More file actions
37 lines (32 loc) · 899 Bytes
/
drizzle.config.ts
File metadata and controls
37 lines (32 loc) · 899 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
36
37
import { defineConfig } from "drizzle-kit";
if (!process.env.DATABASE_URL) {
throw new Error(
"DATABASE_URL is not set. Please ensure the database is provisioned and the environment variable is set.",
);
}
// Parse the connection string
const url = new URL(process.env.DATABASE_URL);
const dbName = url.pathname.replace(/^\//, "");
// Extract username and password from URL
const [username, password] = url.username
? [url.username, url.password]
: [undefined, undefined];
// Extract host and port
const host = url.hostname;
const port = url.port ? parseInt(url.port) : 5432;
export default defineConfig({
out: "./migrations",
schema: "./shared/schema.ts",
dialect: "postgresql",
dbCredentials: {
host,
port,
user: username,
password,
database: dbName,
ssl: {
rejectUnauthorized: false, // Only for development
},
},
verbose: true,
});