Skip to content

Programmable API still uses CLI arguments #449

@Wenzil

Description

@Wenzil

I'm trying to run migrations at start up of the server. Problem is I launch the server with CLI arguments that conflict with db-migrate's. db-migrate tries to use those arguments but they aren't at all intended for db-migrate.

For example, specifying test timeout of test runner lab using the -m CLI argument:

NODE_ENV=test DATABASE_URL=postgres://[email protected]:5432/mydb node_modules/.bin/lab -m 10000 test/integration

throws the following error:

{ err: null,
  originalErr: 
   { [Error: ENOENT: no such file or directory, scandir '/Users/myuser/projects/myproject/ 10000']
     errno: -2,
     code: 'ENOENT',
     syscall: 'scandir',
     path: '/Users/myuser/projects/myproject/ 10000' } }

because db-migrate interprets the -m CLI argument as the migrations directory.

This leakage of CLI arguments should not occur. Eventually it would be nice to be able to specify any option exposed by the CLI to the programmable API.

Here's the snippet that throws the error:

const dbMigrate = require('db-migrate').getInstance(true)
dbMigrate.up()

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions