I had recently upgraded my typeorm version and was following this post (https://wanago.io/2022/07/25/api-nestjs-database-migrations-typeorm/) to set up the migration mechanism
As mentioned in the post, i have a similar typeOrm config file which looks like the following
import { DataSource } from 'typeorm'
import { ConfigService } from '@nestjs/config'
import { config } from 'dotenv'
config()
const configService = new ConfigService()
console.log('Config', configService.get('TYPEORM_HOST'))
export default new DataSource({
type: 'postgres',
host: configService.get('TYPEORM_HOST'),
port: configService.get('TYPEORM_PORT'),
username: configService.get('TYPEORM_USERNAME'),
password: configService.get('TYPEORM_PASSWORD'),
database: configService.get('TYPEORM_DATABASE'),
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
synchronize: configService.get('TYPEORM_SYNCHRONIZE'),
logging: configService.get('TYPEORM_LOGGING'),
migrations: [configService.get('TYPEORM_MIGRATIONS')],
migrationsRun: configService.get('TYPEORM_MIGRATIONS_RUN'),
// subscribers: [configService.get('TYPEORM_SUBSCRIBERS')],
})
Upon inspecting the console statement the config values don't get picked up, any ideas on what is missing here? I even tried providing a path to the config() function and still the same