【问题标题】:Can't make my Phoenix app build on Heroku CI无法在 Heroku CI 上构建我的 Phoenix 应用程序
【发布时间】:2017-11-29 08:49:40
【问题描述】:

我无法让我的 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 中的 repo 设置

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, []}]

【问题讨论】:

    标签: heroku elixir phoenix-framework heroku-ci


    【解决方案1】:

    可能是 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,并且它只运行您希望它运行的命令。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-10
      • 2014-08-15
      • 2017-03-16
      • 2018-04-04
      相关资源
      最近更新 更多