All files / apps/properties-service/src/config typeorm.config.ts

100% Statements 4/4
100% Branches 10/10
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  2x 2x           2x     3x                              
import { DataSourceOptions } from 'typeorm';
import { CreatePropertiesTable1753057000000 } from '../database/migrations/1753057000000-create-properties-table';
import { Property } from '../properties/property.entity';
 
/**
 * Single source of truth for database options, shared by the Nest application
 * and the TypeORM CLI data source so they can never drift apart.
 */
export function buildDataSourceOptions(
  env: Record<string, string | undefined>,
): DataSourceOptions {
  return {
    type: 'postgres',
    host: env.PROPERTIES_DB_HOST ?? 'localhost',
    port: parseInt(env.PROPERTIES_DB_PORT ?? '5432', 10),
    username: env.PROPERTIES_DB_USER ?? 'propflow',
    password: env.PROPERTIES_DB_PASSWORD ?? 'propflow',
    database: env.PROPERTIES_DB_NAME ?? 'properties',
    // Explicit lists (no glob paths): globs break under webpack bundling and jest.
    entities: [Property],
    migrations: [CreatePropertiesTable1753057000000],
    // Schema changes only go through reviewed migrations, never auto-sync.
    synchronize: false,
    migrationsRun: true,
  };
}