How should I initialize my schema via node/npm/knex?

你。 提交于 2019-12-12 04:16:09

问题


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:


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.



来源:https://stackoverflow.com/questions/41027538/how-should-i-initialize-my-schema-via-node-npm-knex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!