ruby-on-rails - ActiveRecord::JDBCError: 错误:无法打开扩展控制文件

标签 ruby-on-rails postgresql jruby

这可能是 Google 界面问题的根源,但我还无法发现任何问题。任何指示都会有所帮助。

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)'

最佳答案

dblink 扩展未随主 PostgreSQL 包一起安装在此系统上,因此用户必须单独安装它。查看评论。

关于ruby-on-rails - ActiveRecord::JDBCError: 错误:无法打开扩展控制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14541576/

相关文章:

postgresql - Amazon RDS PostgreSQL 不接受端口 5432 上的 TCP 连接

java - 将编译好的 Rails 应用程序部署到 Heroku 上的 Java 服务器

jruby - 缺少logstash的jruby gem

ruby-on-rails - 如何根据用户属性清晰地向用户呈现不同的文本?

ruby-on-rails - 带参数的复杂 if 条件

postgresql - 选择多行,每列都有条件

mysql - 从sql中提取数据,修改它并将结果保存到表中

java - 将 Jruby ScriptEngine 输出重定向到 StringWriter

ruby-on-rails - Rails 删除目标 ="_blank"

ruby-on-rails - 格式-在选择标签中自定义空白选项