Guilhem Fry
Guilhem Fry

Reputation: 326

Run Knex migration from node server

I want to run these knex commands automatically every time my app is starting :

knex migrate:make createUserTable
knex migrate:latest

How to do so using my knex object, from my server.js node file, not console command ? Thank you

Upvotes: 1

Views: 2970

Answers (1)

zacurry
zacurry

Reputation: 906

Check out the migration API

In your case it should be :

knex.migrate.make(createUserTable)  

(untested)

Upvotes: 4

Related Questions