I am using TypeORM with a ormconfig.ts file, and I am trying to generate a migration in a specific path using the following command:
yarn typeorm -d ./ormconfig.ts migration:generate ./src/migrations/
However, instead of generating the migration in the ./src/migrations/ folder as expected, it is being generated in ./src.
Here is my ormconfig.ts file:
import * as dotenv from 'dotenv';
import { DataSource } from 'typeorm';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
dotenv.config({
path: `.env`,
});
const config = {
type: (process.env.PROJECT_DB_CONNECTION ?? 'postgres') as PostgresConnectionOptions['type'],
host: process.env.PROJECT_DB_HOST,
port: parseInt(`${process.env?.PROJECT_DB_PORT ?? '5432'}`),
username: process.env.PROJECT_DB_USERNAME,
password: process.env.PROJECT_DB_PASSWORD,
database: process.env.PROJECT_DB_DATABASE,
ssl: process.env.PROJECT_DB_SSL_CERT
? {
rejectUnauthorized: true,
ca: process.env.PROJECT_DB_SSL_CERT,
}
: false,
entities: [__dirname + '/src/modules/**/*.entity.ts'],
namingStrategy: new SnakeNamingStrategy(),
migrations: ['src/migrations/*{.ts,.js}'],
seeds: ['src/seeders/**.seeder{.ts,.js}'],
cli: {
migrationsDir: 'src/migrations',
},
};
export default new DataSource(config);
I am specifying the correct migrationsDir in the cli section of the config, and yet the migrations are being placed in the wrong directory. Does anyone know why this might be happening and how to fix it?
I am expecting to have the migration file to be generated in the path src/migrations, instead of src.