0

I can't manage to make my Phoenix 1.2 app to run on Heroku CI.

It seems it's trying to create a new database, and even though I configured an alias, it's still performing ecto.create.

Here is Heroku CI output:

-----> 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

My mix.exs aliases function

  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

And my repo setup in 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, []}]
Chris
  • 2,744
  • 3
  • 24
  • 39

1 Answers1

0

It might be that mix ecto.setup is being called as part of the preparations to run your tests. HerokuCI seems to use an app.json file for configuration of your tests. This is an example I found at https://devcenter.heroku.com/articles/heroku-ci

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

Make sure that the correct test-setup is configured and that it only runs the commands you want it to run.

supernova32
  • 321
  • 4
  • 14