customink / secondbase

Seamless second database integration for Rails.
MIT License
220 stars 31 forks source link

`rake db:second_base:rollback` ignores config.second_base.config_key #33

Closed aschmied closed 2 months ago

aschmied commented 8 years ago

Steps

  1. create a new second database with a non-default config_key in database.yml
  2. set config.second_base.config_key in an initializer to point to the new key
  3. generate a migration and run it using rake db:migrate
  4. attempt to roll back the migration using rake db:second_base:rollback

Result

> rake db:second_base:rollback
rake aborted!
TypeError: can't dup NilClass
C:\jruby\jruby-9.1.2.0\bin\rake:22:in `<top>'
Tasks: TOP => db:second_base:rollback
(See full trace by running task with --trace)

Expected

Migration is rolled back successfully

Note

If I change the config_key in "database.yml" back to secondbase then rake db:second_base:rollback works as expected.

Environment

Jruby 9.1.2.0, Windows 10, secondbase 2.1.0

hmadison commented 8 years ago

Can you provide the output of rake db:second_base:rollback --trace?

hmadison commented 8 years ago

And your rails version?

aschmied commented 8 years ago

I've included some warnings that I omitted in the original report.

> jruby bin\rake db:second_base:rollback --trace
jruby: warning: unknown property jruby.cext.enabled
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rubyzip-1.1.7/lib/zip.rb:35: warning: ObjectSpace impacts performance. See http://wiki.jruby.org/PerformanceTuning#dont-enable-objectspace
** Invoke db:second_base:rollback (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:second_base:rollback
rake aborted!
TypeError: can't dup NilClass
org/jruby/RubyKernel.java:1886:in `dup'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/activerecord-4.2.5.2/lib/active_record/connection_handling.rb:62:in `initialize'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/activerecord-4.2.5.2/lib/active_record/core.rb:46:in `configurations='
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/secondbase-2.1.0/lib/second_base/on_base.rb:17:in `on_base'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/secondbase-2.1.0/lib/second_base/databases.rake:55:in `block in (root)'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/task.rb:248:in `block in execute'
org/jruby/RubyArray.java:1593:in `each'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/task.rb:243:in `execute'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
C:/jruby/jruby-9.1.2.0/lib/ruby/stdlib/monitor.rb:214:in `mon_synchronize'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/task.rb:173:in `invoke'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/application.rb:150:in `invoke_task'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
org/jruby/RubyArray.java:1593:in `each'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
C:/jruby/jruby-9.1.2.0/lib/ruby/gems/shared/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
bin\rake:4:in `<top>'
Tasks: TOP => db:second_base:rollback
> jruby bin\rails --version
jruby: warning: unknown property jruby.cext.enabled
Rails 4.2.5.2
hmadison commented 8 years ago

Sorry it took so long to get back to you, this appears to be a duplicate of #24. Can you try the mitigation steps listed there and see if they help?