-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Issue type:
[ ] question
[x ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x ] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
https://github.com/joalorro/typeorm-cli-bug
I'm currently attempting to have a Node file programmatically generate migrations via the TypeORM CLI, but I get the error "TypeError: str.replace is not a function". When running the same command via NPM, the migration is successfully created.
I console.log'd the variable "args" within MigrationGenerateCommand.js on line 92 (below "case 8:") and found that it looks like:
{
_: [ 'migration:generate', 'initial' ], // extra element
config: 'ormconfig.json',
f: 'ormconfig.json',
n: true, // bolean
name: true, //boolean
c: 'default',
connection: 'default',
'$0': 'node_modules/typeorm/cli.js'
}
when it should look like:
{
_: [ 'migration:generate' ],
config: 'ormconfig.json',
f: 'ormconfig.json',
n: 'initial', //string
name: 'initial', //string
c: 'default',
connection: 'default',
'$0': 'node_modules/typeorm/cli.js'
}
The latter object is produced when running the package.json scripts, and String.replace is attempting to run on args.name, which is now a boolean.
Node command: node migration.js initial
NPM command: npm run typeorm:migrate initial
// package.json
{
...,
scripts: {
...,
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config ormconfig.json",
"typeorm:migrate": "npm run typeorm migration:generate -- -n",
}
}