-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrizzle.config.ts
More file actions
39 lines (33 loc) · 1.07 KB
/
drizzle.config.ts
File metadata and controls
39 lines (33 loc) · 1.07 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
import { defineConfig } from 'drizzle-kit';
// Determine SSL configuration
const getSSLConfig = () => {
const host = process.env.POSTGRES_HOST || 'localhost';
const sslMode = process.env.POSTGRES_SSL;
// When SSL is explicitly disabled
if (sslMode === 'false') {
return false;
}
// When SSL is explicitly enabled
if (sslMode === 'true' || sslMode === 'require') {
return { rejectUnauthorized: false };
}
// Disable SSL for local environment, enable for production
if (host === 'localhost' || host === '127.0.0.1') {
return false;
}
// Production environment default
return { rejectUnauthorized: false };
};
export default defineConfig({
schema: './src/lib/db/schema.ts',
out: './drizzle',
dialect: 'postgresql',
dbCredentials: {
host: process.env.POSTGRES_HOST || 'localhost',
port: parseInt(process.env.POSTGRES_PORT || '5432'),
user: process.env.POSTGRES_USER || 'postgres',
password: process.env.POSTGRES_PASSWORD || 'password',
database: process.env.POSTGRES_DATABASE || 'crm_db',
ssl: getSSLConfig(),
},
});