我应该如何通过node/npm/knex初始化我的架构? [英] How should I initialize my schema via node/npm/knex?

查看:140
本文介绍了我应该如何通过node/npm/knex初始化我的架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们项目中的每个新开发人员都被要求做:

Every new dev in our project is asked to do:

要首次创建数据库,请运行:$ mysql -u root -p< sql/schema.sql

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

我们在项目内部使用knex. 我们如何使用它来创建模式或手动mysql命令?我们如何为此连接npm?

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?

我们应该在npm install还是npm init上执行此操作?我们如何将这些构建目标连接到knex?

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

推荐答案

通常来说,shell脚本可以满足您的需求:

Generally speaking, a shell script may satisfy your needs:

  • 创建数据库
  • knex最新迁移
  • knex运行种子

npm scripts是您想要的,从技术上讲,它只是打开另一个外壳并在其中运行命令.

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

这篇关于我应该如何通过node/npm/knex初始化我的架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆