Skip to content

Commit

Permalink
Raise an error if adapter is not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
scrogson committed Apr 21, 2015
1 parent 95bc882 commit bb97e15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions installer/lib/phoenix_new.ex
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ defmodule Mix.Tasks.Phoenix.New do
end

def run(app, mod, path, opts) do
db = Keyword.get(opts, :database, "postgres")
dev = Keyword.get(opts, :dev, false)
ecto = Keyword.get(opts, :ecto, true)
brunch = Keyword.get(opts, :brunch, true)

{adapter_app, adapter_module} = set_ecto_adapter(opts[:database])
{adapter_app, adapter_module} = set_ecto_adapter(db)
pubsub_server = set_pubsub_server(mod)

binding = [application_name: app,
Expand Down Expand Up @@ -332,7 +333,8 @@ defmodule Mix.Tasks.Phoenix.New do

defp set_ecto_adapter("mssql"), do: {:tds_ecto, Tds.Ecto}
defp set_ecto_adapter("mysql"), do: {:mariaex, Ecto.Adapters.MySQL}
defp set_ecto_adapter(_), do: {:postgrex, Ecto.Adapters.Postgres}
defp set_ecto_adapter("postgres"), do: {:postgrex, Ecto.Adapters.Postgres}
defp set_ecto_adapter(db), do: Mix.raise "Unknown database #{inspect db}"

defp set_pubsub_server(module) do
module
Expand Down

0 comments on commit bb97e15

Please sign in to comment.