是什么导致 knex migrate:latest 在 Shippable 中失败?

What's causing knex migrate:latest to fail in Shippable?

我正在努力在 Shippable 上建立一个 CI 环境。我现在有一个测试数据库,我需要 运行 针对它进行迁移,但我收到一个对我来说毫无意义的错误

正在执行的构建步骤是这样的:

(cd www && NODE_ENV=test knex --knexfile ./config/knexplus.js migrate:latest)

输出是这样的:

Working directory changed to ~/src/github.com/org/api/www/config
Using environment: test
Knex:warning - Pool2 - Error: Pool was destroyed
Knex:Error Pool2 - Error: ER_DBACCESS_DENIED_ERROR: Access denied for user ''@'localhost' to database 'my_test'
Knex:Error Pool2 - Error: ER_DBACCESS_DENIED_ERROR: Access denied for user ''@'localhost' to database 'my_test'
Error: Pool was destroyed

不要误会我的意思,我理解这条消息,但不知道我为什么会收到它。在 运行 迁移之前,我让构建转储了 knexplus.js 文件内容:

(cd www && cat ./config/knexplus.js)
  'use strict';

  exports.vagrant = exports.staging = exports.production = {
      client: 'mysql',
      connection: {
          host: '127.0.0.1',
          port: '3306',
          user: 'shippable',
          password: '',
          database: 'mine',
          timezone: 'UTC',
          charset: 'utf8',
          debug: false
      },
      migrations: {
          tableName: '_migrations',
          directory: '../db/migrations'
      },
      seeds: {
          directory: '../db/seeds'
      }
  };

  exports.test = {
      client: 'mysql',
      connection: {
          host: '127.0.0.1',
          port: '3306',
          user: 'shippable',
          password: '',
          database: 'my_test',
          timezone: 'UTC',
          charset: 'utf8',
          debug: false
      },
      migrations: {
          tableName: '_migrations',
          directory: '../db/migrations'
      },
      seeds: {
          directory: '../db/seeds'
      }
  };

我注意到错误消息似乎表明我们正在获取正确的配置,因为它引用了 my_test 数据库,但是用户名和主机是错误的。

知道我在这里可能遗漏了什么吗?

我最终输入了支持票并得到了这样的回复:

The databases in the new default images don't have a "shippable" user, so MySQL notices that someone is trying to connect as a user that doesn't exist and tries to see if you can connect without a username. You can either create a shippable user by adding mysql -e "GRANT ALL ON *.* TO shippable@localhost IDENTIFIED BY ''; FLUSH PRIVILEGES;" to your shippable.yml in the ci section before connecting or connect as the root user.

我当时阅读的所有文档都有 shippable 用户。我想第一步是找到 正确的 文档。