gigalixir / gigalixir-cli

MIT License
52 stars 45 forks source link

gigalixir run ecto.migrate not working #34

Closed leom806 closed 5 years ago

leom806 commented 5 years ago

Hey guys, it is my first time using Gigalixir but I'm stuck here with this error:

Running: gigalixir run mix ecto.create return me this in gigalixir logs

web.1  | 03:41:05.114 [error] Postgrex.Protocol (#PID<0.283.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused

I've created the Phoenix project and then followed the docs to deploy it, not sure why I am getting this error when I try to run all my migrations because I did create the database using gigalixir pg:create --free and my prod.exs is as follow:

config :chat, ChatWeb.Endpoint,
  http: [port: {:system, "PORT"}], # Possibly not needed, but doesn't hurt
  url: [host: System.get_env("APP_NAME") <> ".gigalixirapp.com", port: 80],
  secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE"),
  server: true

config :chat, ChatWeb.Repo,
  adapter: Ecto.Adapters.Postgres,
  url: System.get_env("DATABASE_URL"),
  ssl: true,
  pool_size: 2 # Free tier db only allows 4 connections. Rolling deploys need pool_size*(n+1) connections.

Let me know if you guys need any more details

jesseshieh commented 5 years ago

Try changing ChatWeb.Repo to Chat.Repo. That's a common mistake we see a lot. Let me know if that fixes it.

leom806 commented 5 years ago

Oops, yeah, thank you, I should have seen that anyway.

I then got another error, my database was not created but I changed my connection on development environment to point to the gigalixir config database url and ran the mix ecto.migrate "locally" which get it to work now.

Probably my setup has more inconsistencies but it might help someone in the learning process as me.

Thank you, @jesseshieh!