mirror of https://github.com/buster-so/buster.git
database ssl connection fix
This commit is contained in:
parent
c9f5a64999
commit
e63fd79df5
|
@ -10,12 +10,20 @@ if (!connectionString) {
|
|||
throw new Error('DATABASE_URL environment variable is not defined');
|
||||
}
|
||||
|
||||
// Disable SSL for local development
|
||||
const isDevelopment = process.env.ENVIRONMENT === 'development' || process.env.NODE_ENV === 'development';
|
||||
|
||||
// Append sslmode=disable for local development if not already present
|
||||
const dbUrl = isDevelopment && !connectionString.includes('sslmode=')
|
||||
? `${connectionString}?sslmode=disable`
|
||||
: connectionString;
|
||||
|
||||
export default defineConfig({
|
||||
schema: './src/schema.ts',
|
||||
out: './drizzle',
|
||||
dialect: 'postgresql',
|
||||
dbCredentials: {
|
||||
url: connectionString || '',
|
||||
url: dbUrl || '',
|
||||
},
|
||||
verbose: true,
|
||||
strict: true,
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
import { config } from 'dotenv';
|
||||
import * as path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
// Get the directory name for ES modules
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// Load environment variables from root .env file
|
||||
config({ path: path.resolve(__dirname, '../../../.env') });
|
||||
|
||||
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
||||
import postgres from 'postgres';
|
||||
|
@ -49,12 +60,17 @@ export function initializePool<T extends Record<string, postgres.PostgresType>>(
|
|||
}
|
||||
|
||||
// Create postgres client with pool configuration
|
||||
// Disable SSL for local development
|
||||
const isDevelopment = process.env.ENVIRONMENT === 'development' || process.env.NODE_ENV === 'development';
|
||||
|
||||
console.log('Database connection - ENVIRONMENT:', process.env.ENVIRONMENT, 'NODE_ENV:', process.env.NODE_ENV, 'isDevelopment:', isDevelopment);
|
||||
|
||||
globalPool = postgres(connectionString, {
|
||||
max: poolSize,
|
||||
idle_timeout: 30,
|
||||
connect_timeout: 30,
|
||||
prepare: true,
|
||||
ssl: {
|
||||
ssl: isDevelopment ? false : {
|
||||
rejectUnauthorized: false, // Allow self-signed certificates
|
||||
},
|
||||
...config,
|
||||
|
|
17
turbo.json
17
turbo.json
|
@ -100,6 +100,23 @@
|
|||
"env": [
|
||||
"NODE_TLS_REJECT_UNAUTHORIZED"
|
||||
]
|
||||
},
|
||||
"db:seed": {
|
||||
"cache": false,
|
||||
"env": [
|
||||
"DATABASE_URL",
|
||||
"ENVIRONMENT",
|
||||
"NODE_ENV"
|
||||
]
|
||||
},
|
||||
"db:init": {
|
||||
"cache": false,
|
||||
"dependsOn": ["db:migrate"],
|
||||
"env": [
|
||||
"DATABASE_URL",
|
||||
"ENVIRONMENT",
|
||||
"NODE_ENV"
|
||||
]
|
||||
}
|
||||
},
|
||||
"globalEnv": [
|
||||
|
|
Loading…
Reference in New Issue