Permalink
Browse files

Respect rails path configuration for migrations (which defaults to db…

…/migrations; resolves #38
  • Loading branch information...
1 parent 1c8c749 commit 4eacaf96d3c6cc6096bf83d544327c6f9aaf746a @tpitale tpitale committed Jul 29, 2016
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/dm-rails/railties/database.rake
@@ -1,6 +1,10 @@
require 'dm-rails/setup'
require 'dm-rails/storage'
+def migration_paths
+ Rails.configuration.paths['db/migrate'].map {|path| path+"/*.rb"}
+end
+
namespace :db do
desc 'Create the database, load the schema, and initialize with the seed data'
@@ -58,7 +62,8 @@ namespace :db do
namespace :migrate do
task :load => :environment do
require 'dm-migrations/migration_runner'
- FileList['db/migrate/*.rb'].each do |migration|
+
+ FileList[migration_paths].each do |migration|
load migration
end
end
@@ -76,7 +81,7 @@ namespace :db do
desc 'Migrate the database to the latest version'
task :migrate do
- migrate_task = if Dir['db/migrate/*.rb'].empty?
+ migrate_task = if migration_paths.all? { |path| Dir[path].empty? }
'db:autoupgrade'
else
'db:migrate:up'

0 comments on commit 4eacaf9

Please sign in to comment.