aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-12-06 18:57:19 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-12-06 18:57:19 +0000
commit699da7001b9e3d35c282ab3eb5371ba668bdeaa3 (patch)
treefa7000dedc893ebd54b0fdce07857f3946789f9d /railties/lib
parentee6232e6077b8178adf04626c0797594a673dcc2 (diff)
downloadrails-699da7001b9e3d35c282ab3eb5371ba668bdeaa3.tar.gz
rails-699da7001b9e3d35c282ab3eb5371ba668bdeaa3.tar.bz2
rails-699da7001b9e3d35c282ab3eb5371ba668bdeaa3.zip
The test task stops with a warning if you have pending migrations. Closes #10377.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8324 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/tasks/databases.rake15
1 files changed, 14 insertions, 1 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index aa347381a6..aa23eec6e5 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -125,6 +125,19 @@ namespace :db do
puts "Current version: #{ActiveRecord::Migrator.current_version}"
end
+ 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 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
+ end
+
namespace :fixtures do
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
task :load => :environment do
@@ -290,7 +303,7 @@ namespace :db do
end
desc 'Prepare the test database and load the schema'
- task :prepare => :environment do
+ task :prepare => %w(environment db:abort_if_pending_migrations) do
if defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke
end