Files
SerpentRace/SerpentRace_Backend/src/Infrastructure/ormconfig.ts
T

20 lines
855 B
TypeScript

import { DataSource } from 'typeorm';
import { join } from 'path';
// Use .js extension in production (compiled) and .ts in development
const ext = __filename.endsWith('.js') ? 'js' : 'ts';
export const AppDataSource = new DataSource({
type: 'postgres',
host: process.env.DB_HOST || 'localhost',
port: parseInt(process.env.DB_PORT || '5432'),
username: process.env.DB_USERNAME || 'postgres',
password: process.env.DB_PASSWORD || 'postgres',
database: process.env.DB_NAME || 'serpentrace',
synchronize: false, // Set to false when using migrations
logging: process.env.NODE_ENV === 'development',
entities: [join(__dirname, `../Domain/**/*Aggregate.${ext}`)],
migrations: [join(__dirname, `./Migrations/*.${ext}`)],
migrationsTableName: 'migrations',
migrationsRun: false // Let migrations run manually
});