使用官方 redmine 网站(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 设置需要被覆盖?如果没有,我应该如何从这里开始?在这一点上我没有想法。