try one more time without custom ssl

This commit is contained in:
dal 2025-09-20 16:41:34 -06:00
parent ece2be1065
commit 1acecff3a4
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
1 changed files with 0 additions and 25 deletions

View File

@ -1,6 +1,5 @@
import { config } from 'dotenv';
import { defineConfig } from 'drizzle-kit';
import * as fs from 'fs';
// Load specific .env file
config({ path: '../../.env' }); // or '.env.development', '.env.production', etc.
@ -11,36 +10,12 @@ if (!connectionString) {
throw new Error('DATABASE_URL environment variable is not defined');
}
// Check if we have a certificate file specified
const certPath = process.env.DATABASE_SSL_CERT;
const isLocalhost = connectionString.includes('localhost') || connectionString.includes('127.0.0.1');
// Configure SSL based on environment
let sslConfig: any = undefined;
if (!isLocalhost) {
if (certPath && fs.existsSync(certPath)) {
// Use the certificate if available
sslConfig = {
ca: fs.readFileSync(certPath),
rejectUnauthorized: true, // With a proper cert, we can validate
};
console.log('Using SSL certificate from:', certPath);
} else {
// Fallback to allowing self-signed certificates
sslConfig = {
rejectUnauthorized: false,
};
console.log('SSL certificate not found, allowing self-signed certificates');
}
}
export default defineConfig({
schema: './src/schema.ts',
out: './drizzle',
dialect: 'postgresql',
dbCredentials: {
url: connectionString || '',
...(sslConfig && { ssl: sslConfig }),
},
verbose: true,
strict: true,