【问题标题】:Run knex migration during heroku buildpack在 heroku buildpack 期间运行 knex 迁移
【发布时间】:2016-03-23 17:13:38
【问题描述】:

我正在使用 the meteor buildpack 来部署我的流星应用程序。

我希望能够在 buildpack 安装结束时使用 knex 运行迁移。

我派生了 buildpack 以在 extra 目录中添加一个 shell 脚本(如 README 中所述),其中包含:cd .knex && knex migrate:latest --env staging

很遗憾,buildpack 当前目录中没有任何.knex 目录。

我在 heroku buildpack 期间运行 ls -a 以显示当前目录的内容,但没有 .knex 目录:

remote: .
remote: ..
remote: app
remote: assets
remote: boot.js
remote: boot-utils.js
remote: config.json
remote: mini-files.js
remote: node_modules
remote: npm
remote: npm-shrinkwrap.json
remote: package.json
remote: packages
remote: program.json
remote: shell-server.js

有什么建议吗?

【问题讨论】:

    标签: heroku knex.js buildpack


    【解决方案1】:

    如果您有一个迁移文件夹,最初是在 CLI 中创建的:knex migrate:make migration_name,那么您可以根据文档使用:knex.migrate.latest([config]) 在应用程序本身内触发迁移到最新版本:http://knexjs.org/#Migrations-latest

    配置应该按照knexfile.js,我在这里按照一个示例供参考:http://www.dancorman.com/knex-your-sql-best-friend/

    【讨论】:

    • 也可以添加到package.json > scripts: "postinstall": "knex migrate:latest"。此外,您可以使用 heroku-postbuild 代替 postinstall 来指定 heroku。
    猜你喜欢
    • 2016-11-02
    • 2013-11-30
    • 1970-01-01
    • 2021-05-11
    • 2017-02-07
    • 1970-01-01
    • 2020-01-17
    • 1970-01-01
    • 2015-11-11
    相关资源
    最近更新 更多