Project

General

Profile

Actions

Defect #4394

closed

Broken db:migrate:plugins

Added by Alexey Palazhchenko over 14 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Plugin API
Target version:
-
Start date:
2009-12-14
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Commit r3090 (Converted Menus to a Tree structure to allow submenus) broke rake task db:migrate:plugins.

$ rake db:drop db:create db:migrate db:migrate:plugins
...
==  AddVersionsSharing: migrated (0.0133s) ====================================

rake aborted!
undefined method `migration_directory' for #<Rails::GemPlugin:0xb7178600>

(See full trace by running task with --trace)

Files

Actions #1

Updated by Alexey Palazhchenko over 14 years ago

Specifying plugin name doesn't helps:

$ rake db:drop db:create db:migrate
$ rake --trace db:migrate:plugins PLUGIN=test_plugin

(in /home/aleksi/MyCode/redmine-github)
** Invoke db:migrate:plugins (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate:plugins
rake aborted!
undefined method `migration_directory' for #<Rails::GemPlugin:0xb7015de4>
/home/aleksi/MyCode/redmine-github/vendor/plugins/engines/tasks/engines.rake:40
/home/aleksi/MyCode/redmine-github/vendor/plugins/engines/tasks/engines.rake:39:in `each'
/home/aleksi/MyCode/redmine-github/vendor/plugins/engines/tasks/engines.rake:39
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/home/aleksi/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/aleksi/.rvm/gems/ruby/1.8.7/gems/rake-0.8.7/bin/rake:31
/home/aleksi/.rvm/ruby-1.8.7-p174/bin/rake:22:in `load'
/home/aleksi/.rvm/ruby-1.8.7-p174/bin/rake:22

Actions #2

Updated by Mischa The Evil over 14 years ago

Can you provide the output of ./script/about (see SubmittingBugs)?

Actions #3

Updated by Alexey Palazhchenko over 14 years ago

$ ruby script/about 
About your application's environment                      
Ruby version              1.8.7 (i686-linux)              
RubyGems version          1.3.5                           
Rack version              1.0                             
Rails version             2.3.4                           
Active Record version     2.3.4                           
Active Resource version   2.3.4                           
Action Mailer version     2.3.4                           
Active Support version    2.3.4                           
Application root          /home/aleksi/Sites/redmine      
Environment               development                     
Database adapter          mysql                           
Database schema version   20091205124427

Same error with Ruby 1.8.6-p383.

Actions #4

Updated by Alexey Lustin over 14 years ago

same problem

$ ruby script/about 
Ruby version              1.8.6 (i386-mswin32)
RubyGems version          1.3.5
Rack version              1.0
Rails version             2.3.4
Active Record version     2.3.4
Active Resource version   2.3.4
Action Mailer version     2.3.4
Active Support version    2.3.4
Application root          D:/work/development/Docflow/redmine-docflow
Environment               development
Database adapter          sqlite3
Database schema version   20091205124427

About your Redmine plugins
Kanban   0.1.1

the Exception

undefined method `migration_directory' for #<Rails::GemPlugin:0x3ef4248>

in the vendor/plugins/engines/tasks/engines.rake:40
Engines.plugins.each do |plugin|
  next unless File.exists? plugin.migration_directory # Exception in this line
  puts "Migrating plugin #{plugin.name} ..." 
  plugin.migrate
end

with plugin.name rubytree

Engines.plugins collect the list with Engines:Plugin object, but the last element is the type Rails::Gem

see the Netbeans debugger screenshots below

Actions #5

Updated by Alexey Lustin over 14 years ago

this dirty hack resolve this problem

in the vendor/plugins/engines/tasks/engines.rake:39
add new line ;-)

Engines.plugins.each do |plugin|
  next unless plugin.class.to_s.eql? "Engines::Plugin" 
  next unless File.exists? plugin.migration_directory # Exception in this line
  puts "Migrating plugin #{plugin.name} ..." 
  plugin.migrate
end

plugins start migrate correctly, but this is NOT correct coding

Actions #6

Updated by Alexey Lustin over 14 years ago

GemPlugin collecting because the Engines expect as Plugin also a gems
see the in the boot.rb

# initialize Rails::Configuration with our own default values to spare users 
# some hassle with the installation and keep the environment cleaner

{ :default_plugin_locators => (defined?(Gem) ? [Rails::Plugin::GemLocator] : []).push(Engines::Plugin::FileSystemLocator),
:default_plugin_loader => Engines::Plugin::Loader,
:default_plugins => [:engines, :all] }.each do |name, default|    
Rails::Configuration.send(:define_method, name) { default }
end

see the Rails::Plugin::GemLocator ? - gems must be added to plugins migrations, but GemPlugin does not contain method migration_directory, that's why we have an Exception.

how we must wait for Eric Davis - what he say about this.

P.S. In my production i add a dirty hack because i don't use the plugins as gems

Actions #7

Updated by Jean-Philippe Lang over 14 years ago

  • Status changed from New to Closed
  • Affected version (unused) set to devel
  • Resolution set to Fixed

Fix committed in r3186.

Actions #8

Updated by Alexey Palazhchenko over 14 years ago

Thanks, Jean-Philippe.

Actions #9

Updated by Eric Davis over 14 years ago

I'll see about submitting this fix back to the Rails Engines project.

Actions

Also available in: Atom PDF