Permalink
Browse files

Refactor db:load:config to automatically pick additional migrations i…

…f ENGINE_PATH is available
  • Loading branch information...
drogus committed Dec 8, 2010
1 parent 843130d commit 7b9f634e15bfc3f92f4ac7e18537443a55306c10
@@ -3,6 +3,12 @@ db_namespace = namespace :db do
require 'active_record'
ActiveRecord::Base.configurations = Rails.application.config.database_configuration
ActiveRecord::Migrator.migrations_paths = Rails.application.paths["db/migrate"].to_a
+
+ if defined?(ENGINE_PATH) && engine = Rails::Engine.find(ENGINE_PATH)
+ if engine.paths["db/migrate"].existent
+ ActiveRecord::Migrator.migrations_paths += engine.paths["db/migrate"].to_a
+ end
+ end
end
namespace :create do
@@ -70,16 +70,6 @@ def test_dummy_config
if mountable?
template "rails/routes.rb", "#{dummy_path}/config/routes.rb", :force => true
end
-
- if full? && !options[:skip_active_record]
- append_file "#{dummy_path}/Rakefile", <<-EOF
-
-task :"db:load_config" do
- ActiveRecord::Migrator.migrations_paths = Rails.application.config.paths["db/migrate"].to_a +
- <%= camelized %>::Engine.config.paths["db/migrate"].to_a
-end
- EOF
- end
end
def test_dummy_clean
@@ -17,12 +17,8 @@ end
<% if full? && !options[:skip_active_record] -%>
namespace :app do
+ ENGINE_PATH = File.expand_path("..", __FILE__)
load File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__)
-
- task :"db:load_config" do
- ActiveRecord::Migrator.migrations_paths = Rails.application.config.paths["db/migrate"].to_a +
- <%= camelized %>::Engine.config.paths["db/migrate"].to_a
- end
end
<% end -%>

0 comments on commit 7b9f634

Please sign in to comment.