ActiveRecord :: ConnectionNotEstablished with postgres

时间:2013-10-10 14:24:17

标签: ruby-on-rails ruby rails-activerecord redmine rails-postgresql

我使用提供的脚本on the official redmine website(Luciano Pacheco,2011-06-07 06:28版本)将数据从JIRA迁移到Redmine时遇到以下异常:

-bash-4.1$ rake --trace jira_migration:do_all_migrations RAILS_ENV="production"
rake aborted!
ActiveRecord::ConnectionNotEstablished
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/model_schema.rb:223:in `table_exists?'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/attribute_methods/primary_key.rb:75:in `get_primary_key'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/attribute_methods/primary_key.rb:60:in `reset_primary_key'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/attribute_methods/primary_key.rb:49:in `primary_key'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/attribute_assignment.rb:13:in `attributes_protected_by_default'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:216:in `block in protected_attributes_configs'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:188:in `yield'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:188:in `default'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:188:in `protected_attributes'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:118:in `block in attr_protected'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:117:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:117:in `attr_protected'
/opt/redmine/redmine/app/models/tracker.rb:38:in `<class:Tracker>'
/opt/redmine/redmine/app/models/tracker.rb:18:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/opt/redmine/redmine-2.3.3/lib/tasks/migrate_jira.rake:5:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:425:in `block in load_tasks'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:425:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:425:in `load_tasks'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:145:in `load_tasks'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/opt/redmine/redmine-2.3.3/Rakefile:7:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
-bash-4.1$ 

我的 database.yml 看起来像这样(只有postgres生产部分处于活动状态):

# Default setup is given for MySQL with ruby1.9. If you're running Redmine
# with MySQL and ruby1.8, replace the adapter name with `mysql`.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).

#production:
#  adapter: mysql2
#  database: redmine
#  host: localhost
#  port: 3306
#  username: root
#  password: ""
#  encoding: utf8

#development:
#  adapter: mysql2
#  database: redmine_development
#  host: localhost
#  username: root
#  password: ""
#  encoding: utf8

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
#test:
#  adapter: mysql2
#  database: redmine_test
#  host: localhost
#  username: root
#  password: ""
#  encoding: utf8

# PostgreSQL configuration example
production:
  adapter: postgresql
  database: redmine
  host: localhost
  port: 5432
  username: redmine
  password: "canBeCrackedPrettyFast"

# SQLite3 configuration example
#production:
#  adapter: sqlite3
#  database: db/redmine.sqlite3

# SQL Server configuration example
#production:
#  adapter: sqlserver
#  database: redmine
#  host: localhost
#  username: jenkins
#  password: jenkins

现在,在我的 postgres.conf 中,我打开了

log_connections = on
log_disconnections = on

选项,所以我可以看到会话何时开始和停止。当我使用psql客户端访问我的redmine数据库时,我可以立即看到预期的日志条目(它只是声明redmine用户已登录并注销,对非英语消息道歉):

2013-10-10 16:18:53 CESTLOG:  Verbindung empfangen: Host=172.30.5.77 Port=48393
2013-10-10 16:18:53 CESTLOG:  Verbindung authorisiert: Benutzer=redmine Datenbank=redmine
2013-10-10 16:18:57 CESTLOG:  Verbindungsende: Sitzungszeit: 0:00:06.710 Benutzer=redmine Datenbank=redmine Host=172.30.5.77 port=48393

但是,当我运行上面提到的脚本时,没有任何内容被记录,这让我觉得ActiveRecord不会从我的database.yml加载数据或者加载它不正确。我的问题是:是否需要覆盖任何标准的ActiveRecord设置?如果没有,我该如何从这里开始?我现在没有想法。

0 个答案:

没有答案