How should I initialize my schema via node/npm/kne

2019-09-15 04:52发布

Every new dev in our project is asked to do:

To create the database for the first time, run: $ mysql -u root -p < sql/schema.sql

We're using knex internally in the project. How can we use it to create the schema instead or manual mysql commands? How do we hook up npm for that?

Should we do it on npm install, or npm init? How do we hook up those build targets to knex?

1条回答
Fickle 薄情
2楼-- · 2019-09-15 05:32

Generally speaking, a shell script may satisfy your needs:

  • create database
  • knex migrate latest
  • knex run seeds

npm scripts is what you want, technically, it just open another shell and run commands in it.

查看更多
登录 后发表回答