I'm generating migrations using TypeOrm in NestJS but I don't know why it creates the migration file at the root every time and I want it to automatically create the migration file into /src/server/migration/ folder.
ormconfig.ts
import * as dotenv from 'dotenv';
import { DataSource } from 'typeorm';
dotenv.config();
const connection = new DataSource({
type: 'postgres' as const,
host: 'localhost',
port: 5432,
username: 'username',
password: 'password',
database: 'database',
entities: ['src/server/entity/*.{ts,js}'],
migrations: ['src/server/migration/*.{ts,js}'],
extra: {
ssl: false,
},
});
export default connection;
package.json
{
"scripts": {
"typeorm": "typeorm-ts-node-esm --dataSource ./ormconfig.ts",
"migration:gen": "npm run typeorm migration:generate -n",
},
"dependencies": {
"typeorm": "^0.3.6",
}
}