Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run knexfile.js from a db/ folder

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!

like image 900
Carol.Kar Avatar asked Oct 25 '25 07:10

Carol.Kar


1 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.

like image 180
TeachMe Avatar answered Oct 26 '25 21:10

TeachMe