27 lines
959 B
TypeScript
27 lines
959 B
TypeScript
import * as path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
import { DataSource } from 'typeorm'
|
|
|
|
// ESM-compatible __dirname
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __dirname = path.dirname(__filename)
|
|
|
|
/**
|
|
* TypeORM DataSource configuration for CLI operations (migrations)
|
|
*
|
|
* Note: Entity glob loading is disabled for migrations to avoid
|
|
* workspace package dependencies. Migrations use raw SQL.
|
|
*/
|
|
export const AppDataSource = new DataSource({
|
|
type: 'postgres',
|
|
host: process.env.DB_HOST || 'localhost',
|
|
port: parseInt(process.env.DB_PORT || '25462', 10),
|
|
username: process.env.DB_USERNAME || 'client_intel',
|
|
password: process.env.DB_PASSWORD || 'devpassword',
|
|
database: process.env.DB_NAME || 'lilith_client_intel',
|
|
entities: [], // Migrations don't need entity definitions
|
|
migrations: [path.join(__dirname, 'migrations/*-*.{ts,js}')],
|
|
synchronize: false,
|
|
logging: process.env.NODE_ENV !== 'production',
|
|
})
|