diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-12-09 04:18:28 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-12-09 04:18:28 +0000 |
commit | 2c951efed3bada5ee5df764926ca90d19a7863c0 (patch) | |
tree | 6bec6b346ee79d104d8966473f42d03b143e2f54 | |
parent | a456388ff92b74918d8b457faf1ede356cc76b2d (diff) | |
download | rails-2c951efed3bada5ee5df764926ca90d19a7863c0.tar.gz rails-2c951efed3bada5ee5df764926ca90d19a7863c0.tar.bz2 rails-2c951efed3bada5ee5df764926ca90d19a7863c0.zip |
Don't check for pending migrations if Active Record isn't loaded
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8338 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | railties/lib/tasks/databases.rake | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index aa23eec6e5..54f9beaede 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -127,14 +127,16 @@ namespace :db do desc "Raises an error if there are pending migrations" task :abort_if_pending_migrations => :environment do - pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations + if defined? ActiveRecord + pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations - if pending_migrations.any? - puts "You have #{pending_migrations.size} pending migrations:" - pending_migrations.each do |pending_migration| - puts ' %4d %s' % [pending_migration.version, pending_migration.name] + if pending_migrations.any? + puts "You have #{pending_migrations.size} pending migrations:" + pending_migrations.each do |pending_migration| + puts ' %4d %s' % [pending_migration.version, pending_migration.name] + end + abort "Run `rake db:migrate` to update your database then try again." end - abort "Run `rake db:migrate` to update your database then try again." end end @@ -304,7 +306,7 @@ namespace :db do desc 'Prepare the test database and load the schema' task :prepare => %w(environment db:abort_if_pending_migrations) do - if defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank? + if defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank? Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke end end |