1
我在跟随this tutorial,它在config.exs
和extensions
字段中添加了postgrex扩展。不过,现在已添加postgrex扩展的方式已过时,我们现在应该使用type
字段而不是extensions
字段。我下面就以geo library github page的代码,添加扩展:尝试实施“geo”postgrex扩展类型时出错
config.exs
Postgrex.Types.define(MyApp.PostgresTypes,
[Geo.PostGIS.Extension] ++ Ecto.Adapters.Postgres.extensions(),
json: Poison)
use Mix.Config
config :api, Api.Repo,
types: MyApp.PostgresTypes,
adapter: Ecto.Adapters.Postgres,
database: "api_repo",
username: "postgres",
password: "postgres",
hostname: "localhost",
web_port: String.to_integer(System.get_env("PORT") || "4000"),
timeout: 60_000,
pool_timeout: 60_000
config :api, ecto_repos: [Api.Repo]
但我发现了这个错误:
bash-3.2$ mix ecto.migrate
** (Mix.Config.LoadError) could not load config config/config.exs
** (UndefinedFunctionError) function Ecto.Adapters.Postgres.extensions/0 is undefined (module Ecto.Adapt
ers.Postgres is not available)
Ecto.Adapters.Postgres.extensions()
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(stdlib) erl_eval.erl:470: :erl_eval.expr/5
(stdlib) erl_eval.erl:878: :erl_eval.expr_list/6
(stdlib) erl_eval.erl:404: :erl_eval.expr/5
(stdlib) erl_eval.erl:122: :erl_eval.exprs/5
我已经在网上看到这有时是由于version of postgrex,但这是一个非常旧的版本,我使用{:postgrex, "~> 0.13.2"},
。我错过了什么?
你下载并安装了PostGIS吗? –
@a_horse_with_no_name啊,没有。我只是将Geo安装为dep:'[{:geo,“〜> 1.4”}]'在我的代理中。我将下载PostGis – BeniaminoBaggins
您使用的是哪种版本的Ecto? (详见mix.lock) – Dogbert