Run knexfile.js from a db/ folder

Viewed 1550

I have installed the nodejs package globally.

After initializing via knex init and putting the file into a /db folder, commands such as knex migrate:latest won`t work anymore, because knex cannot find the file. Furthermore, knex creates the migrate and seed folder in my root directory

Any suggestions how to config knex that it always looks into the /db folder? Is there any way to do this via a node-script?

Thanks for your reply!

2 Answers

You can give your config file location on script

add this on package.json

"migrate": "yarn knex migrate:latest --knexfile src/config/knexfile.js",

My knexfile is in src/config.

Write your own client implementation which just uses migration API provided by knex.

Related