0
我使用Postgres(PostgreSQL)9.3.5與我的Rails(4.0.1)應用程序和Ruby(2.0.0-p451),其中一個遷移看起來像:無法爲Postgres創建擴展
class CreateExtensions< ActiveRecord::Migration
def up
connection = ActiveRecord::Base.connection
extensions = %w(fuzzystrmatch hstore plpgsql postgis postgis_tiger_geocoder postgis_topology)
ext_query = extensions.map {|e| "CREATE EXTENSION IF NOT EXISTS #{e};" }.join
connection.execute(ext_query)
end
end
每當我試着運行遷移文件,我得到以下錯誤:
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;CREATE EXTENSION IF NOT EXISTS hstore;CREATE EXTENSION IF NOT EXISTS plpgsql;CREATE EXTENSION IF NOT EXISTS postgis;CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;CREATE EXTENSION IF NOT EXISTS postgis_topology;
PG::UndefinedFile: ERROR: could not open extension control file "/usr/local/Cellar/postgresql/9.3.5_1/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;CREATE EXTENSION IF NOT EXISTS hstore;CREATE EXTENSION IF NOT EXISTS plpgsql;CREATE EXTENSION IF NOT EXISTS postgis;CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;CREATE EXTENSION IF NOT EXISTS postgis_topology;
ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR: could not open extension control file "/usr/local/Cellar/postgresql/9.3.5_1/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;CREATE EXTENSION IF NOT EXISTS hstore;CREATE EXTENSION IF NOT EXISTS plpgsql;CREATE EXTENSION IF NOT EXISTS postgis;CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;CREATE EXTENSION IF NOT EXISTS postgis_topology;
from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `async_exec'
from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:435:in `block in log'
from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:430:in `log'
from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
from (irb):14
from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.1/lib/rails/commands/console.rb:90:in `start'
from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.1/lib/rails/commands/console.rb:9:in `start'
from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.1/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我使用自制安裝Postgres的,知不知道我在做什麼錯在這裏?
您是否安裝PostGIS? – 2014-10-07 11:41:42
是的,我使用自制軟件,我已經安裝了postgis-2.1.4_1。 – 2014-10-07 12:49:08
@NickVeys,我需要安裝不同的版本嗎?感謝您的幫助 – 2014-10-07 12:53:30