0

这可能是谷歌界面问题的一个椅子,但我还不能发现任何东西。任何指针都会有所帮助。

JRuby 1.6.8 Rails 3.2.11 Postgres 9.1 Ubuntu 12.04

我有一个 RAILS 迁移:

class AddDblinkToEnrollmentsShards < ActiveRecord::Migration
  db_magic :connections => [:enrollments_shard_one, :enrollments_shard_two, :enrollments_shard_three, :enrollments_shard_four]

  def change
    execute "CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;"
  end
end

我不断收到这个错误:

-- execute("CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;")
  [enrollments_shard_one]   (16.0ms)  CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
ActiveRecord::JDBCError: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/dblink.control": No such file or directory: CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
==  AddDblinkToEnrollmentsShards: Switching connection back ===================
rake aborted!
An error has occurred, this and all later migrations canceled:

ActiveRecord::JDBCError: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/dblink.control": No such file or directory: CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
arjdbc/jdbc/RubyJdbcConnection.java:195:in `execute'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:217:in `_execute'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:209:in `execute'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `log'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activesupport-3.2.11/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/rails3/abstract_adapter/connection_name.rb:14:in `instrument'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/instrumentation/active_record.rb:32:in `log_with_newrelic_instrumentation'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:240:in `trace_execution_scoped'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/instrumentation/active_record.rb:29:in `log_with_newrelic_instrumentation'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:209:in `execute'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2130:in `send'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:466:in `method_missing'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `say_with_time'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `say_with_time'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:458:in `method_missing'
/home/scott/source/unicon/unicon-ttm-sandbox/db/migrate/20130103134257_add_dblink_to_enrollments_shards.rb:5:in `change'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:407:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:407:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:389:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:86:in `migrate_with_db_wrapper'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:125:in `on_db'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:123:in `on_db'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:85:in `migrate_with_db_wrapper'
org/jruby/RubyArray.java:1620:in `each'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:84:in `migrate_with_db_wrapper'
org/jruby/RubyBasicObject.java:1704:in `__send__'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:528:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:720:in `migrate'
org/jruby/RubyProc.java:258:in `call'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `ddl_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:491:in `transaction_with_trace_ActiveRecord_self_name_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:240:in `trace_execution_scoped'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:486:in `transaction_with_trace_ActiveRecord_self_name_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `ddl_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:719:in `migrate'
org/jruby/RubyArray.java:1620:in `each'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:570:in `up'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:557:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:179:in `(root)'
org/jruby/RubyProc.java:258:in `call'
org/jruby/RubyArray.java:1620:in `each'
org/jruby/RubyArray.java:1620:in `each'
org/jruby/RubyKernel.java:1097:in `load'
org/jruby/RubyKernel.java:1117:in `eval'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bin/ruby_noexec_wrapper:14:in `(root)'
4

3 回答 3

3

dblink扩展未与该系统上的主 PostgreSQL 软件包一起安装,因此用户必须单独安装。看评论。

于 2013-01-27T04:40:24.190 回答
1

在 CentOS 上:

sudo yum install postgres*contrib

登录数据库,运行:

CREATE EXTENSION dblink;
于 2014-03-14T21:24:30.543 回答
1

对于安装了多个 pg 版本的情况,用户还需要通过指定版本来安装 contrib 包:

sudo apt-get install postgresql-contrib-9.1
于 2014-11-17T20:46:11.943 回答