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
This commit is contained in:
Jeremy Kemper 2007-12-09 04:18:28 +00:00
parent a456388ff9
commit 2c951efed3
1 changed files with 9 additions and 7 deletions

View File

@ -127,6 +127,7 @@ namespace :db do
desc "Raises an error if there are pending migrations"
task :abort_if_pending_migrations => :environment do
if defined? ActiveRecord
pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations
if pending_migrations.any?
@ -137,6 +138,7 @@ namespace :db do
abort "Run `rake db:migrate` to update your database then try again."
end
end
end
namespace :fixtures do
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
@ -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