I tried this command in different possible ways but the basic structure of my command was.
yarn typeorm migration:generate -n=consent-record -d=\"./src/db/CliDataSource.ts\"
this is my typeorm command in the package.json for yarn berry
"typeorm": "ts-node -P ./tsconfig.typeorm.json $(yarn bin typeorm) -d ./src/db/CliDataSource.ts",
I also tried installing typeorm locally as an npm. and also tried with npx. but they all give the following error. "Not enough non-option arguments: got 0, need at least 1" this error clearly doesn't mention what is missing.
my CliDataSource goes like this.
export const CliDataSource = new DataSource({
type: 'postgres',
host: 'localhost',
port: 5436,
username: '****',
password: '******',
database: 'consent',
synchronize: false,
logging: false,
entities,
migrations,
migrationsRun: true,
subscribers: [],
});
I am using typeorm "^0.3.6"
Latest updates to the typeorm has removed -n flag which we used to rename migrations. how it works now is that we need to provide the migration file path. that will store the migration in that specified file. so the updated operations were
my typeorm alias inside package.json.
"typeorm": "ts-node -P ./tsconfig.typeorm.json $(yarn bin typeorm) -d ./src/db/CliDataSource.ts",
CLI Command
yarn typeorm migration:generate ./src/db/migrations/consent-record
The official documentation seems outdated. hope it will be updated soon.
Special thanks to Jacob Copini @woov