0

我无法让我的 Phoenix 1.2 应用程序在 Heroku CI 上运行。

它似乎正在尝试创建一个新数据库,即使我配置了别名,它仍然在执行ecto.create.

这是 Heroku CI 输出:

-----> Running Elixir buildpack tests... 10:25:25.751 [warn] Warning: No valid AppSignal configuration found, continuing with AppSignal metrics disabled. 10:25:26.071 [error] GenServer #PID<0.903.0> terminating
** (Postgrex.Error) FATAL (insufficient_privilege): permission denied for database "template1" User does not have CONNECT privilege.
    (db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3 Last message: nil
** (Mix) The database for PhenixDisplays.Repo couldn't be created: FATAL (insufficient_privilege): permission denied for database "template1" User does not have CONNECT privilege.
-----> Elixir buildpack tests failed with exit status 1

我的mix.exs别名功能

  defp aliases do
    [
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      "test": ["ecto.migrate", "test"]
    ]
  end

我的回购设置在test.exs

config :phenix_displays, PhenixDisplays.Repo,
  adapter: Ecto.Adapters.Postgres,
  url: System.get_env("DATABASE_URL") || "postgres://postgres:postgres@localhost:5432/phenix_displays_test",
  pool: Ecto.Adapters.SQL.Sandbox,
  extensions: [{Geo.PostGIS.Extension, library: Geo}, {PhenixDisplays.Postgrex.Box2D, []}]
4

1 回答 1

0

这可能是mix ecto.setup作为运行测试准备工作的一部分而被调用的。HerokuCI 似乎使用app.json文件来配置您的测试。这是我在https://devcenter.heroku.com/articles/heroku-ci找到的示例

{
  "environments": {
    "test": {
      "scripts": {
        "test-setup": "gem install rubocop",
        "test": "rubocop ."
      }
    }
  }
}

确保test-setup配置正确并且它只运行您希望它运行的命令。

于 2017-06-27T00:05:43.477 回答