Created
August 13, 2009 16:55
-
-
Save jamiew/167296 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? | |
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 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment