I am learning about migrations in NestJs typeorm so when i specfied the cli property to typeormconfig file it says that the cli property dont exist.
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { join } from 'path';
const typeConfigDatabase: TypeOrmModuleOptions = {
type: 'postgres',
host: process.env.POSTGRES_HOST,
port: Number(process.env.POSTGRES_PORT),
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
entities: [join(__dirname, '**', '*.entity.{ts,js}')],
synchronize: false,
migrations: ['dist/src/db/migrations/*.js'],
cli: {
migrationsDir: 'src/db/migrations',
},
};
I was expecting that on running the migration command the migration folder will be created but its not. The Error is :
Object literal may only specify known properties, and 'cli' does not exist in type '{ retryAttempts?: number; retryDelay?: number; toRetry?: (err: any) => boolean; autoLoadEntities?: boolean; keepConnectionAlive?: boolean; verboseRetryLog?: boolean; } &
Since you are using
typeormversion of0.3or higher, thecli.migrationsDiroption do not exist anymore.You'll have to use the new way to generate migrations: https://github.com/typeorm/typeorm/issues/8810
Basically, you need to have two options in typeorm config:
migrationsTableNamemigrationsThen use the CLI to create the migration:
Refer to https://typeorm.io/migrations#creating-a-new-migration for more details.