我如何 运行 针对远程数据库进行 Knex 迁移?

How do I run a Knex migration against a remote database?

我有一个远程数据库,我想 运行 针对 Knex 迁移。

我看到 Knex CLI 文档中有一个 --connection 标志,但是当我尝试

knex migrate:latest --connection [[my connection string]

我明白了

error: unknown option `--connection'

http://knexjs.org/#Migrations-CLI

您的项目文件夹中应该有 knexfile.js。 文件应包含如下内容:

module.exports = {
  development: {
    client: 'mysql',
    connection: {
      host : '127.0.0.1', // should be remote host
      user : 'your_database_user',
      password : 'your_database_password',
      database : 'myapp_test'
    }
  }
}

然后你可以运行迁移

来自 npx knex migrate:latest